String

struct String
  • A method used to retrieve a value from a given dictionary for a specific key. - parameter dictionary: A Dictionary with String keys and JSON values. - throws: .KeyNotFound with an associated value of self, where self is a String, should the key not be present within the JSON. - returns: The JSON value associated with the given key.

    Declaration

    Swift

    public func value(in dictionary: [String : JSON]) throws -> JSON

    Parameters

    dictionary

    A Dictionary with String keys and JSON values.

    Return Value

    The JSON value associated with the given key.

  • Converts an instance of a conforming type to JSON. - returns: An instance of JSON where the enum case is .string.

    Declaration

    Swift

    public func toJSON() -> JSON

    Return Value

    An instance of JSON where the enum case is .string.

  • An initializer to create an instance of String from a JSON value. - parameter json: An instance of JSON. - throws: The initializer will throw an instance of JSON.Error if an instance of String cannot be created from the JSON value that was passed to this initializer.

    Declaration

    Swift

    public init(json: JSON) throws

    Parameters

    json

    An instance of JSON.