JSON

public enum JSON

An enum to describe the structure of JSON.

  • A case for denoting an array with an associated value of [JSON]

    Declaration

    Swift

    case array([JSON])
  • A case for denoting a dictionary with an associated value of [Swift.String: JSON]

    Declaration

    Swift

    case dictionary([String: JSON])
  • A case for denoting a double with an associated value of Swift.Double.

    Declaration

    Swift

    case double(Double)
  • int

    A case for denoting an integer with an associated value of Swift.Int.

    Declaration

    Swift

    case int(Int)
  • A case for denoting a string with an associated value of Swift.String.

    Declaration

    Swift

    case string(String)
  • A case for denoting a boolean with an associated value of Swift.Bool.

    Declaration

    Swift

    case bool(Bool)
  • A case for denoting null.

    Declaration

    Swift

    case null
  • Attempt to serialize JSON into an Data. - returns: A byte-stream containing the JSON ready for wire transfer. - throws: Errors that arise from JSONSerialization. - see: Foundation.JSONSerialization

    Declaration

    Swift

    public func serialize() throws -> Data

    Return Value

    A byte-stream containing the JSON ready for wire transfer.

  • Attempt to serialize JSON into a String. - returns: A String containing the JSON. - throws: A JSON.Error.StringSerializationError or errors that arise from JSONSerialization. - see: Foundation.JSONSerialization

    Declaration

    Swift

    public func serializeString() throws -> String

    Return Value

    A String containing the JSON.

  • An enum to encapsulate errors that may arise in working with JSON.

    See more

    Declaration

    Swift

    public enum Error: Swift.Error
  • A textual representation of self.

    Declaration

    Swift

    public var description: Swift.String
  • Attempts to decode into the returning type from a path into JSON. - parameter path: 0 or more String or Int that subscript the JSON. - parameter type: If the context this method is called from does not make the return type clear, pass a type implementing JSONDecodable to disambiguate the type to decode with. - returns: An initialized member from the inner JSON. - throws: One of the following errors contained in JSON.Error: * KeyNotFound: A given String key does not exist inside a descendant JSON dictionary. * IndexOutOfBounds: A given Int index is outside the bounds of a descendant JSON array. * UnexpectedSubscript: A given subscript cannot be used with the corresponding JSON value. * TypeNotConvertible: The target value’s type inside of the JSON instance does not match Decoded.

    Declaration

    Swift

    public func decode<Decoded: JSONDecodable>(at path: JSONPathType..., type: Decoded.Type = Decoded.self) throws -> Decoded

    Parameters

    path

    0 or more String or Int that subscript the JSON.

    type

    If the context this method is called from does not make the return type clear, pass a type implementing JSONDecodable to disambiguate the type to decode with.

    Return Value

    An initialized member from the inner JSON.

  • Retrieves a Double from a path into JSON. - parameter path: 0 or more String or Int that subscript the JSON - returns: A floating-point Double - throws: One of the JSON.Error cases thrown by decode(at:type:). - seealso: JSON.decode(at:type:)

    Declaration

    Swift

    public func getDouble(at path: JSONPathType...) throws -> Double

    Parameters

    path

    0 or more String or Int that subscript the JSON

    Return Value

    A floating-point Double

  • Retrieves an Int from a path into JSON. - parameter path: 0 or more String or Int that subscript the JSON - returns: A numeric Int - throws: One of the JSON.Error cases thrown by decode(at:type:). - seealso: JSON.decode(at:type:)

    Declaration

    Swift

    public func getInt(at path: JSONPathType...) throws -> Int

    Parameters

    path

    0 or more String or Int that subscript the JSON

    Return Value

    A numeric Int

  • Retrieves a String from a path into JSON. - parameter path: 0 or more String or Int that subscript the JSON - returns: A textual String - throws: One of the JSON.Error cases thrown by decode(at:type:). - seealso: JSON.decode(at:type:)

    Declaration

    Swift

    public func getString(at path: JSONPathType...) throws -> String

    Parameters

    path

    0 or more String or Int that subscript the JSON

    Return Value

    A textual String

  • Retrieves a Bool from a path into JSON. - parameter path: 0 or more String or Int that subscript the JSON - returns: A truthy Bool - throws: One of the JSON.Error cases thrown by decode(at:type:). - seealso: JSON.decode(at:type:)

    Declaration

    Swift

    public func getBool(at path: JSONPathType...) throws -> Bool

    Parameters

    path

    0 or more String or Int that subscript the JSON

    Return Value

    A truthy Bool

  • Retrieves a [JSON] from a path into JSON. - parameter path: 0 or more String or Int that subscript the JSON - returns: An Array of JSON elements - throws: One of the JSON.Error cases thrown by decode(at:type:). - seealso: JSON.decode(at:type:)

    Declaration

    Swift

    public func getArray(at path: JSONPathType...) throws -> [JSON]

    Parameters

    path

    0 or more String or Int that subscript the JSON

    Return Value

    An Array of JSON elements

  • Attempts to decode many values from a descendant JSON array at a path into JSON. - parameter path: 0 or more String or Int that subscript the JSON - parameter type: If the context this method is called from does not make the return type clear, pass a type implementing JSONDecodable to disambiguate the type to decode with. - returns: An Array of decoded elements - throws: One of the JSON.Error cases thrown by decode(at:type:), or any error that arises from decoding the contained values. - seealso: JSON.decode(at:type:)

    Declaration

    Swift

    public func decodedArray<Decoded: JSONDecodable>(at path: JSONPathType..., type: Decoded.Type = Decoded.self) throws -> [Decoded]

    Parameters

    path

    0 or more String or Int that subscript the JSON

    type

    If the context this method is called from does not make the return type clear, pass a type implementing JSONDecodable to disambiguate the type to decode with.

    Return Value

    An Array of decoded elements

  • Retrieves a [String: JSON] from a path into JSON. - parameter path: 0 or more String or Int that subscript the JSON - returns: An Dictionary of String mapping to JSON elements - throws: One of the JSON.Error cases thrown by decode(at:type:). - seealso: JSON.decode(at:type:)

    Declaration

    Swift

    public func getDictionary(at path: JSONPathType...) throws -> [String: JSON]

    Parameters

    path

    0 or more String or Int that subscript the JSON

    Return Value

    An Dictionary of String mapping to JSON elements

  • Attempts to decode many values from a descendant JSON object at a path into JSON. - parameter path: 0 or more String or Int that subscript the JSON - parameter type: If the context this method is called from does not make the return type clear, pass a type implementing JSONDecodable to disambiguate the value type to decode with. - returns: A Dictionary of String keys and decoded values. - throws: One of the JSON.Error cases thrown by decode(at:type:) or any error that arises from decoding the contained values. - seealso: JSON.decode(at:type:)

    Declaration

    Swift

    public func decodedDictionary<Decoded: JSONDecodable>(at path: JSONPathType..., type: Decoded.Type = Decoded.self) throws -> [String: Decoded]

    Parameters

    path

    0 or more String or Int that subscript the JSON

    type

    If the context this method is called from does not make the return type clear, pass a type implementing JSONDecodable to disambiguate the value type to decode with.

    Return Value

    A Dictionary of String keys and decoded values.

  • An OptionSetType used to represent the different options available for subscripting JSON with null values or missing keys. * .NullBecomesNil - Treat null values as nil. * .MissingKeyBecomesNil - Treat missing keys as nil.

    See more

    Declaration

    Swift

    public struct SubscriptingOptions: OptionSet
  • Optionally decodes into the returning type from a path into JSON. - parameter path: 0 or more String or Int that subscript the JSON - parameter alongPath: Options that control what should be done with values that are null or keys that are missing. - parameter type: If the context this method is called from does not make the return type clear, pass a type implementing JSONDecodable to disambiguate the type to decode with. - returns: A decoded value from the inner JSON if found, or nil. - throws: One of the following errors contained in JSON.Error: * KeyNotFound: A key path does not exist inside a descendant JSON dictionary. * IndexOutOfBounds: An index path is outside the bounds of a descendant JSON array. * UnexpectedSubscript: A path item cannot be used with the corresponding JSON value. * TypeNotConvertible: The target value’s type inside of the JSON instance does not match the decoded value. * Any error that arises from decoding the value.

    Declaration

    Swift

    public func decode<Decoded: JSONDecodable>(at path: JSONPathType..., alongPath options: SubscriptingOptions, type: Decoded.Type = Decoded.self) throws -> Decoded?

    Parameters

    path

    0 or more String or Int that subscript the JSON

    alongPath

    Options that control what should be done with values that are null or keys that are missing.

    type

    If the context this method is called from does not make the return type clear, pass a type implementing JSONDecodable to disambiguate the type to decode with.

    Return Value

    A decoded value from the inner JSON if found, or nil.

  • Optionally retrieves a Double from a path into JSON. - parameter path: 0 or more String or Int that subscript the JSON. - parameter alongPath: Options that control what should be done with values that are null or keys that are missing. - returns: A Double if a value could be found, otherwise nil. - throws: One of the following errors contained in JSON.Error: * KeyNotFound: A key path does not exist inside a descendant JSON dictionary. * IndexOutOfBounds: An index path is outside the bounds of a descendant JSON array. * UnexpectedSubscript: A path item cannot be used with the corresponding JSON value. * TypeNotConvertible: The target value’s type inside of the JSON instance does not match the decoded value.

    Declaration

    Swift

    public func getDouble(at path: JSONPathType..., alongPath options: SubscriptingOptions) throws -> Double?

    Parameters

    path

    0 or more String or Int that subscript the JSON.

    alongPath

    Options that control what should be done with values that are null or keys that are missing.

    Return Value

    A Double if a value could be found, otherwise nil.

  • Optionally retrieves a Int from a path into JSON. - parameter path: 0 or more String or Int that subscript the JSON - parameter alongPath: Options that control what should be done with values that are null or keys that are missing. - returns: A numeric Int if a value could be found, otherwise nil. - throws: One of the following errors contained in JSON.Error: * KeyNotFound: A key path does not exist inside a descendant JSON dictionary. * IndexOutOfBounds: An index path is outside the bounds of a descendant JSON array. * UnexpectedSubscript: A path item cannot be used with the corresponding JSON value. * TypeNotConvertible: The target value’s type inside of the JSON instance does not match the decoded value.

    Declaration

    Swift

    public func getInt(at path: JSONPathType..., alongPath options: SubscriptingOptions) throws -> Int?

    Parameters

    path

    0 or more String or Int that subscript the JSON

    alongPath

    Options that control what should be done with values that are null or keys that are missing.

    Return Value

    A numeric Int if a value could be found, otherwise nil.

  • Optionally retrieves a String from a path into JSON. - parameter path: 0 or more String or Int that subscript the JSON - parameter alongPath: Options that control what should be done with values that are null or keys that are missing. - returns: A text String if a value could be found, otherwise nil. - throws: One of the following errors contained in JSON.Error: * KeyNotFound: A key path does not exist inside a descendant JSON dictionary. * IndexOutOfBounds: An index path is outside the bounds of a descendant JSON array. * UnexpectedSubscript: A path item cannot be used with the corresponding JSON value. * TypeNotConvertible: The target value’s type inside of the JSON instance does not match the decoded value.

    Declaration

    Swift

    public func getString(at path: JSONPathType..., alongPath options: SubscriptingOptions) throws -> String?

    Parameters

    path

    0 or more String or Int that subscript the JSON

    alongPath

    Options that control what should be done with values that are null or keys that are missing.

    Return Value

    A text String if a value could be found, otherwise nil.

  • Optionally retrieves a Bool from a path into JSON. - parameter path: 0 or more String or Int that subscript the JSON - parameter alongPath: Options that control what should be done with values that are null or keys that are missing. - returns: A truthy Bool if a value could be found, otherwise nil. - throws: One of the following errors contained in JSON.Error: * KeyNotFound: A key path does not exist inside a descendant JSON dictionary. * IndexOutOfBounds: An index path is outside the bounds of a descendant JSON array. * UnexpectedSubscript: A path item cannot be used with the corresponding JSON value. * TypeNotConvertible: The target value’s type inside of the JSON instance does not match the decoded value.

    Declaration

    Swift

    public func getBool(at path: JSONPathType..., alongPath options: SubscriptingOptions) throws -> Bool?

    Parameters

    path

    0 or more String or Int that subscript the JSON

    alongPath

    Options that control what should be done with values that are null or keys that are missing.

    Return Value

    A truthy Bool if a value could be found, otherwise nil.

  • Optionally retrieves a [JSON] from a path into the recieving structure. - parameter path: 0 or more String or Int that subscript the JSON - parameter alongPath: Options that control what should be done with values that are null or keys that are missing. - returns: An Array of JSON elements if a value could be found, otherwise nil. - throws: One of the following errors contained in JSON.Error: * KeyNotFound: A key path does not exist inside a descendant JSON dictionary. * IndexOutOfBounds: An index path is outside the bounds of a descendant JSON array. * UnexpectedSubscript: A path item cannot be used with the corresponding JSON value. * TypeNotConvertible: The target value’s type inside of the JSON instance does not match the decoded value.

    Declaration

    Swift

    public func getArray(at path: JSONPathType..., alongPath options: SubscriptingOptions) throws -> [JSON]?

    Parameters

    path

    0 or more String or Int that subscript the JSON

    alongPath

    Options that control what should be done with values that are null or keys that are missing.

    Return Value

    An Array of JSON elements if a value could be found, otherwise nil.

  • Optionally decodes many values from a descendant array at a path into JSON. - parameter path: 0 or more String or Int that subscript the JSON - parameter alongPath: Options that control what should be done with values that are null or keys that are missing. - parameter type: If the context this method is called from does not make the return type clear, pass a type implementing JSONDecodable to disambiguate the value type to decode with. - returns: An Array of decoded elements if found, otherwise nil. - throws: One of the following errors contained in JSON.Error: * KeyNotFound: A key path does not exist inside a descendant JSON dictionary. * IndexOutOfBounds: An index path is outside the bounds of a descendant JSON array. * UnexpectedSubscript: A path item cannot be used with the corresponding JSON value. * TypeNotConvertible: The target value’s type inside of the JSON instance does not match the decoded value. * Any error that arises from decoding the value.

    Declaration

    Swift

    public func decodedArray<Decoded: JSONDecodable>(at path: JSONPathType..., alongPath options: SubscriptingOptions, type: Decoded.Type = Decoded.self) throws -> [Decoded]?

    Parameters

    path

    0 or more String or Int that subscript the JSON

    alongPath

    Options that control what should be done with values that are null or keys that are missing.

    type

    If the context this method is called from does not make the return type clear, pass a type implementing JSONDecodable to disambiguate the value type to decode with.

    Return Value

    An Array of decoded elements if found, otherwise nil.

  • Optionally retrieves a [String: JSON] from a path into the recieving structure. - parameter path: 0 or more String or Int that subscript the JSON - parameter alongPath: Options that control what should be done with values that are null or keys that are missing. - returns: A Dictionary of String mapping to JSON elements if a value could be found, otherwise nil. - throws: One of the following errors contained in JSON.Error: * KeyNotFound: A key path does not exist inside a descendant JSON dictionary. * IndexOutOfBounds: An index path is outside the bounds of a descendant JSON array. * UnexpectedSubscript: A path item cannot be used with the corresponding JSON value. * TypeNotConvertible: The target value’s type inside of the JSON instance does not match the decoded value.

    Declaration

    Swift

    public func getDictionary(at path: JSONPathType..., alongPath options: SubscriptingOptions) throws -> [String: JSON]?

    Parameters

    path

    0 or more String or Int that subscript the JSON

    alongPath

    Options that control what should be done with values that are null or keys that are missing.

    Return Value

    A Dictionary of String mapping to JSON elements if a value could be found, otherwise nil.

  • Optionally attempts to decode many values from a descendant object at a path into JSON. - parameter path: 0 or more String or Int that subscript the JSON - parameter alongPath: Options that control what should be done with values that are null or keys that are missing. - parameter type: If the context this method is called from does not make the return type clear, pass a type implementing JSONDecodable to disambiguate the value type to decode with. - returns: A Dictionary of String mapping to decoded elements if a value could be found, otherwise nil. - throws: One of the following errors contained in JSON.Error: * KeyNotFound: A key path does not exist inside a descendant JSON dictionary. * IndexOutOfBounds: An index path is outside the bounds of a descendant JSON array. * UnexpectedSubscript: A path item cannot be used with the corresponding JSON value. * TypeNotConvertible: The target value’s type inside of the JSON instance does not match the decoded value. * Any error that arises from decoding the value.

    Declaration

    Swift

    public func decodedDictionary<Decoded: JSONDecodable>(at path: JSONPathType..., alongPath options: SubscriptingOptions, type: Decoded.Type = Decoded.self) throws -> [String: Decoded]?

    Parameters

    path

    0 or more String or Int that subscript the JSON

    alongPath

    Options that control what should be done with values that are null or keys that are missing.

    type

    If the context this method is called from does not make the return type clear, pass a type implementing JSONDecodable to disambiguate the value type to decode with.

    Return Value

    A Dictionary of String mapping to decoded elements if a value could be found, otherwise nil.

  • Attempts to decode into the returning type from a path into JSON, or returns a fallback if not found. - parameter path: 0 or more String or Int that subscript the JSON - parameter fallback: Value to use when one is missing at the subscript. - returns: An initialized member from the inner JSON. - throws: One of the following errors contained in JSON.Error: * UnexpectedSubscript: A given subscript cannot be used with the corresponding JSON value. * TypeNotConvertible: The target value’s type inside of the JSON instance does not match Decoded.

    Declaration

    Swift

    public func decode<Decoded: JSONDecodable>(at path: JSONPathType..., or fallback: @autoclosure() -> Decoded) throws -> Decoded

    Parameters

    path

    0 or more String or Int that subscript the JSON

    fallback

    Value to use when one is missing at the subscript.

    Return Value

    An initialized member from the inner JSON.

  • Retrieves a Double from a path into JSON or a fallback if not found. - parameter path: 0 or more String or Int that subscript the JSON - parameter fallback: Double to use when one is missing at the subscript. - returns: A floating-point Double - throws: One of the JSON.Error cases thrown by calling mapOptional(at:fallback:transform:).

    Declaration

    Swift

    public func getDouble(at path: JSONPathType..., or fallback: @autoclosure() -> Double) throws -> Double

    Parameters

    path

    0 or more String or Int that subscript the JSON

    fallback

    Double to use when one is missing at the subscript.

    Return Value

    A floating-point Double

  • Retrieves an Int from a path into JSON or a fallback if not found. - parameter path: 0 or more String or Int that subscript the JSON - parameter fallback: Int to use when one is missing at the subscript. - returns: A numeric Int - throws: One of the following errors contained in JSON.Error: * KeyNotFound: A key path does not exist inside a descendant JSON dictionary. * IndexOutOfBounds: An index path is outside the bounds of a descendant JSON array. * UnexpectedSubscript: A path item cannot be used with the corresponding JSON value. * TypeNotConvertible: The target value’s type inside of the JSON instance does not match the decoded value.

    Declaration

    Swift

    public func getInt(at path: JSONPathType..., or fallback: @autoclosure() -> Int) throws -> Int

    Parameters

    path

    0 or more String or Int that subscript the JSON

    fallback

    Int to use when one is missing at the subscript.

    Return Value

    A numeric Int

  • Retrieves a String from a path into JSON or a fallback if not found. - parameter path: 0 or more String or Int that subscript the JSON - parameter fallback: String to use when one is missing at the subscript. - returns: A textual String - throws: One of the following errors contained in JSON.Error: * KeyNotFound: A key path does not exist inside a descendant JSON dictionary. * IndexOutOfBounds: An index path is outside the bounds of a descendant JSON array. * UnexpectedSubscript: A path item cannot be used with the corresponding JSON value. * TypeNotConvertible: The target value’s type inside of the JSON instance does not match the decoded value.

    Declaration

    Swift

    public func getString(at path: JSONPathType..., or fallback: @autoclosure() -> String) throws -> String

    Parameters

    path

    0 or more String or Int that subscript the JSON

    fallback

    String to use when one is missing at the subscript.

    Return Value

    A textual String

  • Retrieves a Bool from a path into JSON or a fallback if not found. - parameter path: 0 or more String or Int that subscript the JSON - parameter fallback: Bool to use when one is missing at the subscript. - returns: A truthy Bool - throws: One of the following errors contained in JSON.Error: * KeyNotFound: A key path does not exist inside a descendant JSON dictionary. * IndexOutOfBounds: An index path is outside the bounds of a descendant JSON array. * UnexpectedSubscript: A path item cannot be used with the corresponding JSON value. * TypeNotConvertible: The target value’s type inside of the JSON instance does not match the decoded value.

    Declaration

    Swift

    public func getBool(at path: JSONPathType..., or fallback: @autoclosure() -> Bool) throws -> Bool

    Parameters

    path

    0 or more String or Int that subscript the JSON

    fallback

    Bool to use when one is missing at the subscript.

    Return Value

    A truthy Bool

  • Retrieves a [JSON] from a path into JSON or a fallback if not found. - parameter path: 0 or more String or Int that subscript the JSON - parameter fallback: Array to use when one is missing at the subscript. - returns: An Array of JSON elements - throws: One of the following errors contained in JSON.Error: * KeyNotFound: A key path does not exist inside a descendant JSON dictionary. * IndexOutOfBounds: An index path is outside the bounds of a descendant JSON array. * UnexpectedSubscript: A path item cannot be used with the corresponding JSON value. * TypeNotConvertible: The target value’s type inside of the JSON instance does not match the decoded value.

    Declaration

    Swift

    public func getArray(at path: JSONPathType..., or fallback: @autoclosure() -> [JSON]) throws -> [JSON]

    Parameters

    path

    0 or more String or Int that subscript the JSON

    fallback

    Array to use when one is missing at the subscript.

    Return Value

    An Array of JSON elements

  • Attempts to decodes many values from a desendant JSON array at a path into the recieving structure, returning a fallback if not found. - parameter path: 0 or more String or Int that subscript the JSON - parameter fallback: Array to use when one is missing at the subscript. - returns: An Array of decoded elements - throws: One of the following errors contained in JSON.Error: * KeyNotFound: A key path does not exist inside a descendant JSON dictionary. * IndexOutOfBounds: An index path is outside the bounds of a descendant JSON array. * UnexpectedSubscript: A path item cannot be used with the corresponding JSON value. * TypeNotConvertible: The target value’s type inside of the JSON instance does not match the decoded value. * Any error that arises from decoding the value.

    Declaration

    Swift

    public func decodedArray<Decoded: JSONDecodable>(at path: JSONPathType..., or fallback: @autoclosure() -> [Decoded]) throws -> [Decoded]

    Parameters

    path

    0 or more String or Int that subscript the JSON

    fallback

    Array to use when one is missing at the subscript.

    Return Value

    An Array of decoded elements

  • Retrieves a [String: JSON] from a path into JSON or a fallback if not found. - parameter path: 0 or more String or Int that subscript the JSON - parameter fallback: Dictionary to use when one is missing at the subscript. - returns: An Dictionary of String mapping to JSON elements - throws: One of the following errors contained in JSON.Error: * KeyNotFound: A key path does not exist inside a descendant JSON dictionary. * IndexOutOfBounds: An index path is outside the bounds of a descendant JSON array. * UnexpectedSubscript: A path item cannot be used with the corresponding JSON value. * TypeNotConvertible: The target value’s type inside of the JSON instance does not match the decoded value.

    Declaration

    Swift

    public func getDictionary(at path: JSONPathType..., or fallback: @autoclosure() -> [String: JSON]) throws -> [String: JSON]

    Parameters

    path

    0 or more String or Int that subscript the JSON

    fallback

    Dictionary to use when one is missing at the subscript.

    Return Value

    An Dictionary of String mapping to JSON elements

  • Attempts to decode many values from a descendant JSON object at a path into the receiving structure, returning a fallback if not found. - parameter path: 0 or more String or Int that subscript the JSON - parameter fallback: Value to use when one is missing at the subscript - returns: A Dictionary of String mapping to decoded elements. - throws: One of the following errors contained in JSON.Error: * KeyNotFound: A key path does not exist inside a descendant JSON dictionary. * IndexOutOfBounds: An index path is outside the bounds of a descendant JSON array. * UnexpectedSubscript: A path item cannot be used with the corresponding JSON value. * TypeNotConvertible: The target value’s type inside of the JSON instance does not match the decoded value. * Any error that arises from decoding the value.

    Declaration

    Swift

    public func decodedDictionary<Decoded: JSONDecodable>(at path: JSONPathType..., or fallback: @autoclosure() -> [String: Decoded]) throws -> [String: Decoded]

    Parameters

    path

    0 or more String or Int that subscript the JSON

    fallback

    Value to use when one is missing at the subscript

    Return Value

    A Dictionary of String mapping to decoded elements.

  • Create an instance by copying each element of the collection into a new Array.

    Declaration

    Swift

    public init<Collection: Swift.Collection>(_ collection: Collection) where Collection.Iterator.Element == JSON
  • Create an instance initialized with elements.

    Declaration

    Swift

    public init(arrayLiteral elements: JSON...)
  • Create an instance by copying each key/value pair of the pairs into a new Dictionary.

    Declaration

    Swift

    public init<Dictionary: Sequence>(_ pairs: Dictionary) where Dictionary.Iterator.Element == (Swift.String, JSON)
  • Create an instance initialized with pairs.

    Declaration

    Swift

    public init(dictionaryLiteral pairs: (Swift.String, JSON)...)
  • Create an instance initialized to dictionary.

    Declaration

    Swift

    public init(_ dictionary: Swift.Dictionary<Swift.String, JSON>)
  • Create an instance initialized to Double value.

    Declaration

    Swift

    public init(_ value: Swift.Double)
  • Create a literal instance initialized to value.

    Declaration

    Swift

    public init(floatLiteral value: Swift.Double)
  • Create an instance initialized to Int by value.

    Declaration

    Swift

    public init(_ value: Swift.Int)
  • Create a literal instance initialized to value.

    Declaration

    Swift

    public init(integerLiteral value: Swift.Int)
  • Create an instance initialized to String by text.

    Declaration

    Swift

    public init(_ text: Swift.String)
  • Create a literal instance initialized to value.

    Declaration

    Swift

    public init(stringLiteral value: StringLiteralType)
  • Create a literal instance initialized to value.

    Declaration

    Swift

    public init(extendedGraphemeClusterLiteral value: StringLiteralType)
  • Create a literal instance initialized to value.

    Declaration

    Swift

    public init(unicodeScalarLiteral value: StringLiteralType)
  • Create an instance initialized to Bool by value.

    Declaration

    Swift

    public init(_ value: Swift.Bool)
  • Create a literal instance initialized to value.

    Declaration

    Swift

    public init(booleanLiteral value: Swift.Bool)
  • Create an instance initialized with nil.

    Declaration

    Swift

    public init(nilLiteral: ())
  • Retrieves a [JSON] from the JSON. - parameter: A JSON to be used to create the returned Array. - returns: An Array of JSON elements - throws: Any of the JSON.Error cases thrown by decode(type:). - seealso: JSON.decode(_:type:)

    Declaration

    Swift

    static func getArray(from json: JSON) throws -> [JSON]

    Return Value

    An Array of JSON elements

  • Retrieves a [String: JSON] from the JSON. - parameter: A JSON to be used to create the returned Dictionary. - returns: An Dictionary of String mapping to JSON elements - throws: Any of the JSON.Error cases thrown by decode(type:). - seealso: JSON.decode(_:type:)

    Declaration

    Swift

    static func getDictionary(from json: JSON) throws -> [String: JSON]

    Return Value

    An Dictionary of String mapping to JSON elements

  • Attempts to decode many values from a descendant JSON array at a path into JSON. - parameter json: A JSON to be used to create the returned Array of some type conforming to JSONDecodable. - returns: An Array of Decoded elements. - throws: Any of the JSON.Error cases thrown by decode(type:), as well as any error that arises from decoding the contained values. - seealso: JSON.decode(_:type:)

    Declaration

    Swift

    static func decodedArray<Decoded: JSONDecodable>(from json: JSON) throws -> [Decoded]

    Parameters

    json

    A JSON to be used to create the returned Array of some type conforming to JSONDecodable.

    Return Value

    An Array of Decoded elements.

  • Attempts to decode many values from a descendant JSON object at a path into JSON. - parameter json: A JSON to be used to create the returned Dictionary of some type conforming to JSONDecodable. - returns: A Dictionary of string keys and Decoded values. - throws: One of the JSON.Error cases thrown by decode(_:type:) or any error that arises from decoding the contained values. - seealso: JSON.decode(_:type:)

    Declaration

    Swift

    static func decodedDictionary<Decoded: JSONDecodable>(from json: JSON) throws -> [Swift.String: Decoded]

    Parameters

    json

    A JSON to be used to create the returned Dictionary of some type conforming to JSONDecodable.

    Return Value

    A Dictionary of string keys and Decoded values.