/src/swift-protobuf/Sources/SwiftProtobuf/JSONEncodingOptions.swift
Line | Count | Source |
1 | | // Sources/SwiftProtobuf/JSONEncodingOptions.swift - JSON encoding options |
2 | | // |
3 | | // Copyright (c) 2014 - 2018 Apple Inc. and the project authors |
4 | | // Licensed under Apache License v2.0 with Runtime Library Exception |
5 | | // |
6 | | // See LICENSE.txt for license information: |
7 | | // https://github.com/apple/swift-protobuf/blob/main/LICENSE.txt |
8 | | // |
9 | | // ----------------------------------------------------------------------------- |
10 | | /// |
11 | | /// JSON encoding options |
12 | | /// |
13 | | // ----------------------------------------------------------------------------- |
14 | | |
15 | | /// Options for JSONEncoding. |
16 | | public struct JSONEncodingOptions: Sendable { |
17 | | |
18 | | /// Always prints int64s values as numbers. |
19 | | /// By default, they are printed as strings as per proto3 JSON mapping rules. |
20 | | /// NB: When used as Map keys, int64s will be printed as strings as expected. |
21 | 206k | public var alwaysPrintInt64sAsNumbers: Bool = false |
22 | | |
23 | | /// Always print enums as ints. By default they are printed as strings. |
24 | 206k | public var alwaysPrintEnumsAsInts: Bool = false |
25 | | |
26 | | /// Whether to preserve proto field names. |
27 | | /// By default they are converted to JSON(lowerCamelCase) names. |
28 | 206k | public var preserveProtoFieldNames: Bool = false |
29 | | |
30 | | /// Whether to use deterministic ordering when serializing. |
31 | | /// |
32 | | /// Note that the deterministic serialization is NOT canonical across languages. |
33 | | /// It is NOT guaranteed to remain stable over time. It is unstable across |
34 | | /// different builds with schema changes due to unknown fields. Users who need |
35 | | /// canonical serialization (e.g., persistent storage in a canonical form, |
36 | | /// fingerprinting, etc.) should define their own canonicalization specification |
37 | | /// and implement their own serializer rather than relying on this API. |
38 | | /// |
39 | | /// If deterministic serialization is requested, map entries will be sorted |
40 | | /// by keys in lexicographical order. This is an implementation detail |
41 | | /// and subject to change. |
42 | 206k | public var useDeterministicOrdering: Bool = false |
43 | | |
44 | 95.6k | public init() {} |
45 | | } |