<!--
{
  "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/EncodingFormat",
  "metadataVersion" : "0.1.0",
  "role" : "Enumeration",
  "symbol" : {
    "kind" : "Enumeration",
    "modules" : [
      "MetricKit"
    ],
    "preciseIdentifier" : "s:9MetricKit0A6ReportV14EncodingFormatO"
  },
  "title" : "MetricReport.EncodingFormat"
}
-->

# MetricReport.EncodingFormat

A value that controls the JSON structure used when encoding a metric report.

```
enum EncodingFormat
```

## Discussion

Set [`encodingFormatKey`](/documentation/MetricKit/MetricReport/encodingFormatKey) in a `JSONEncoder`’s `userInfo` dictionary to choose the encoding format before archiving reports:

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

The `.byStateReportingDomain` format organizes metric values by [`MetricGroup`](/documentation/MetricKit/MetricGroup), which can be more convenient for log pipelines that process one category at a time.

## Topics

### Encoding formats

[`case `default``](/documentation/MetricKit/MetricReport/EncodingFormat/default)

Default format with state entries and interval entries as arrays.

[`case byStateReportingDomain`](/documentation/MetricKit/MetricReport/EncodingFormat/byStateReportingDomain)

Format with entries organized by StateReporting domain.

## Relationships

### Conforms To

[`Hashable`](/documentation/Swift/Hashable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Sendable`](/documentation/Swift/Sendable)

[`Equatable`](/documentation/Swift/Equatable)

---

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)