NonConformingFloatEncodingStrategy
The strategy to use for non-JSON-conforming floating-point values (IEEE 754 infinity and NaN).
- iOS
- 8.0+
- macOS
- 10.10+
- tvOS
- 9.0+
- watchOS
- 2.0+
enum NonConformingFloatEncodingStrategy
The strategy to use for non-JSON-conforming floating-point values (IEEE 754 infinity and NaN).
enum NonConformingFloatEncodingStrategy
s20FoundationEssentials11JSONEncoderC34NonConformingFloatEncodingStrategyO
What are these?1PD5O
import FoundationEssentials
class JSONEncoder
JSONEncoder
facilitates the encoding of Encodable
values into JSON.
case convertToString(positiveInfinity: String, negativeInfinity: String, nan: String)
Encode the values using the given representation strings.
case `throw`
Throw upon encountering non-conforming values. This is the default strategy.
init()
Initializes self
with default strategies.
var dataEncodingStrategy: JSONEncoder.DataEncodingStrategy { get set }
The strategy to use in encoding binary data. Defaults to .base64
.
var dateEncodingStrategy: JSONEncoder.DateEncodingStrategy { get set }
The strategy to use in encoding dates. Defaults to .deferredToDate
.
var keyEncodingStrategy: JSONEncoder.KeyEncodingStrategy { get set }
The strategy to use for encoding keys. Defaults to .useDefaultKeys
.
var nonConformingFloatEncodingStrategy: JSONEncoder.NonConformingFloatEncodingStrategy { get set }
The strategy to use in encoding non-conforming numbers. Defaults to .throw
.
var outputFormatting: JSONEncoder.OutputFormatting { get set }
The output format to produce. Defaults to []
.
var userInfo: [CodingUserInfoKey : Any] { get set }
Contextual user-provided information for use during encoding.
func encode<T>(_ value: T) throws -> Data where T : Encodable
Encodes the given top-level value and returns its JSON representation.
func encode<T>(_ value: T, configuration: T.EncodingConfiguration) throws -> Data where T : EncodableWithConfiguration
func encode<T, C>(_ value: T, configuration: C.Type) throws -> Data where T : EncodableWithConfiguration, C : EncodingConfigurationProviding, T.EncodingConfiguration == C.EncodingConfiguration
enum DataEncodingStrategy
The strategy to use for encoding Data
values.
enum DateEncodingStrategy
The strategy to use for encoding Date
values.
enum KeyEncodingStrategy
The strategy to use for automatically changing the value of keys before encoding.
struct OutputFormatting
The formatting of the output JSON data.
protocol Sendable