public struct JSONParser
A pure Swift JSON parser. This parser is much faster than the
NSJSONSerialization-based parser (due to the overhead of having to
dynamically cast the Objective-C objects to determine their type); however,
it is much newer and has restrictions that the
does not. Two restrictions in particular are that it requires UTF-8 data as
input and it does not allow trailing commas in arrays or dictionaries.
Decode the root element of the
JSONstream. This may be any fragment or a structural element, per RFC 7159.
The beginning bytes are used to determine the stream’s encoding.
JSONParsercurrently only supports UTF-8 encoding, with or without a byte-order mark.
JSONParser.Errorfor any decoding failures, including a source location if needed.
public mutating func parse() throws -> JSON
Creates an instance of
JSONfrom UTF-8 encoded
Data. - parameter data: An instance of
JSONfrom. - throws: Any
JSONParser.Errorthat arises during decoding. - seealso: JSONParser.parse()
public static func createJSON(from data: Data) throws -> JSON
An instance of