Contents

encodingFormatKey

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

Declaration

static let encodingFormatKey: CodingUserInfoKey

Mentioned in

Discussion

Set this key in a JSONEncoder’s userInfo dictionary before encoding a MetricReport to control the JSON output structure:

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

When omitted, the encoder uses the default format.

See Also

Metric data