Open ClassFoundation5.9.0
JSONDecoder
JSONDecoder
facilitates the decoding of JSON into semantic Decodable
types.
class JSONDecoder
Citizens in Foundation
Members
init(
) Initializes
self
with default strategies.var dataDecodingStrategy: JSONDecoder.DataDecodingStrategy
The strategy to use in decoding binary data. Defaults to
.base64
.var dateDecodingStrategy: JSONDecoder.DateDecodingStrategy
The strategy to use in decoding dates. Defaults to
.deferredToDate
.var keyDecodingStrategy: JSONDecoder.KeyDecodingStrategy
The strategy to use for decoding keys. Defaults to
.useDefaultKeys
.var nonConformingFloatDecodingStrategy: JSONDecoder.NonConformingFloatDecodingStrategy
The strategy to use in decoding non-conforming numbers. Defaults to
.throw
.var userInfo: [CodingUserInfoKey : Any]
Contextual user-provided information for use during decoding.
func decode<T>(T
.Type, from: Data) throws -> T Decodes a top-level value of the given type from the given JSON representation.
enum DataDecodingStrategy
The strategy to use for decoding
Data
values.enum DateDecodingStrategy
The strategy to use for decoding
Date
values.enum KeyDecodingStrategy
The strategy to use for automatically changing the value of keys before decoding.
enum NonConformingFloatDecodingStrategy
The strategy to use for non-JSON-conforming floating-point values (IEEE 754 infinity and NaN).
Extension in NIOFoundationCompat
Members
func decode<T>(T
.Type, from: ByteBuffer) throws -> T Returns a value of the type you specify, decoded from a JSON object inside the readable bytes of a
ByteBuffer
.