<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MetricKit",
  "identifier" : "/documentation/MetricKit/MetricReport/encodingFormatKey",
  "metadataVersion" : "0.1.0",
  "role" : "Type Property",
  "symbol" : {
    "kind" : "Type Property",
    "modules" : [
      "MetricKit"
    ],
    "preciseIdentifier" : "s:9MetricKit0A6ReportV17encodingFormatKeys014CodingUserInfoF0VvpZ"
  },
  "title" : "encodingFormatKey"
}
-->

# encodingFormatKey

A `CodingUserInfoKey` for selecting the JSON encoding format of a metric report.

```
static let encodingFormatKey: CodingUserInfoKey
```

## Discussion

Set this key in a `JSONEncoder`’s `userInfo` dictionary before encoding a [`MetricReport`](/documentation/MetricKit/MetricReport) to control the JSON output structure:

```swift
let encoder = JSONEncoder()
encoder.userInfo[MetricReport.encodingFormatKey] = MetricReport.EncodingFormat.byStateReportingDomain
let data = try encoder.encode(report)
```

When omitted, the encoder uses the default format.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)