ATJSON

public struct ATJSON
extension ATJSON: Collection
extension ATJSON: Swift.ExpressibleByStringLiteral
extension ATJSON: Swift.ExpressibleByIntegerLiteral
extension ATJSON: Swift.ExpressibleByBooleanLiteral
extension ATJSON: Swift.ExpressibleByFloatLiteral
extension ATJSON: Swift.ExpressibleByDictionaryLiteral
extension ATJSON: Swift.ExpressibleByArrayLiteral
extension ATJSON: Swift.ExpressibleByNilLiteral
extension ATJSON: Swift.RawRepresentable
extension ATJSON: Swift.CustomStringConvertible, Swift.CustomDebugStringConvertible
extension ATJSON : Swift.Comparable

Undocumented

  • Creates a JSON using the data.

    Declaration

    Swift

    public init(data: Data, options opt: JSONSerialization.ReadingOptions = .allowFragments, error: NSErrorPointer? = nil)

    Parameters

    data

    The NSData used to convert to json.Top level object in data is an NSArray or NSDictionary

    opt

    The JSON serialization reading options. .AllowFragments by default.

    error

    error The NSErrorPointer used to return the error. nil by default.

    Return Value

    The created JSON

  • Create a JSON from JSON string

    Declaration

    Swift

    public static func parse(_ string: String) -> ATJSON

    Parameters

    string

    Normal json string like ‘{“a”:“b”}’

    Return Value

    The created JSON

  • Creates a JSON using the object.

    Declaration

    Swift

    public init(_ object: Any)

    Parameters

    object

    The object must have the following properties: All objects are NSString/String, NSNumber/Int/Float/Double/Bool, NSArray/Array, NSDictionary/Dictionary, or NSNull; All dictionary keys are NSStrings/String; NSNumbers are not NaN or infinity.

    Return Value

    The created JSON

  • Creates a JSON from a [JSON]

    Declaration

    Swift

    public init(_ jsonArray: [ATJSON])

    Parameters

    jsonArray

    A Swift array of JSON objects

    Return Value

    The created JSON

  • Creates a JSON from a [String: JSON]

    Declaration

    Swift

    public init(_ jsonDictionary: [String : ATJSON])

    Parameters

    jsonDictionary

    A Swift dictionary of JSON objects

    Return Value

    The created JSON

  • Object in JSON

    Declaration

    Swift

    public var object: Any { get set }
  • json type

    Declaration

    Swift

    public var type: Type { get }
  • Error in JSON

    Declaration

    Swift

    public var error: NSError? { get }
  • Undocumented

    Declaration

    Swift

    public static var null: ATJSON { get }

JSON Base

Subscript

  • Find a json in the complex data structuresby using the Int/String’s array.

    let json = JSON[data] let path = [9,“list”,“person”,“name”] let name = json[path]

    The same as: let name = json[9][“list”][“person”][“name”]

    Declaration

    Swift

    public subscript(path: [JSONSubscriptType]) -> ATJSON { get set }

    Parameters

    path

    The target json’s path. Example:

    Return Value

    Return a json found by the path or a null json with error

  • Find a json in the complex data structures by using the Int/String’s array.

    let name = json[9,“list”,“person”,“name”]

    The same as: let name = json[9][“list”][“person”][“name”]

    Declaration

    Swift

    public subscript(path: JSONSubscriptType...) -> ATJSON { get set }

    Parameters

    path

    The target json’s path. Example:

    Return Value

    Return a json found by the path or a null json with error

LiteralConvertible

Raw

  • Declaration

    Swift

    public init?(rawValue: Any)
  • Declaration

    Swift

    public var rawValue: Any { get }
  • Undocumented

    Declaration

    Swift

    public func rawData(options opt: JSONSerialization.WritingOptions = JSONSerialization.WritingOptions(rawValue: 0)) throws -> Data
  • Undocumented

    Declaration

    Swift

    public func rawString(_ encoding: String.Encoding = String.Encoding.utf8, options opt: JSONSerialization.WritingOptions = .prettyPrinted) -> String?

Printable, DebugPrintable

  • Declaration

    Swift

    public var description: String { get }
  • Declaration

    Swift

    public var debugDescription: String { get }

Array

  • Undocumented

    Declaration

    Swift

    public var array: [ATJSON]? { get }
  • Undocumented

    Declaration

    Swift

    public var arrayValue: [ATJSON] { get }
  • Undocumented

    Declaration

    Swift

    public var arrayObject: [Any]? { get set }

Dictionary

  • Undocumented

    Declaration

    Swift

    public var dictionary: [String : ATJSON]? { get }
  • Undocumented

    Declaration

    Swift

    public var dictionaryValue: [String : ATJSON] { get }
  • Undocumented

    Declaration

    Swift

    public var dictionaryObject: [String : Any]? { get set }

Bool

  • Undocumented

    Declaration

    Swift

    public var bool: Bool? { get set }
  • Undocumented

    Declaration

    Swift

    public var boolValue: Bool { get set }

String

  • Undocumented

    Declaration

    Swift

    public var string: String? { get set }
  • Undocumented

    Declaration

    Swift

    public var stringValue: String { get set }

Number

  • Undocumented

    Declaration

    Swift

    public var number: NSNumber? { get set }
  • Undocumented

    Declaration

    Swift

    public var numberValue: NSNumber { get set }

Null

  • Undocumented

    Declaration

    Swift

    public var null: NSNull? { get set }
  • Undocumented

    Declaration

    Swift

    public func exists() -> Bool

URL

  • URL

    Undocumented

    Declaration

    Swift

    public var URL: Foundation.URL? { get set }

Int, Double, Float, Int8, Int16, Int32, Int64

  • Undocumented

    Declaration

    Swift

    public var double: Double? { get set }
  • Undocumented

    Declaration

    Swift

    public var doubleValue: Double { get set }
  • Undocumented

    Declaration

    Swift

    public var float: Float? { get set }
  • Undocumented

    Declaration

    Swift

    public var floatValue: Float { get set }
  • int

    Undocumented

    Declaration

    Swift

    public var int: Int? { get set }
  • Undocumented

    Declaration

    Swift

    public var intValue: Int { get set }
  • Undocumented

    Declaration

    Swift

    public var uInt: UInt? { get set }
  • Undocumented

    Declaration

    Swift

    public var uIntValue: UInt { get set }
  • Undocumented

    Declaration

    Swift

    public var int8: Int8? { get set }
  • Undocumented

    Declaration

    Swift

    public var int8Value: Int8 { get set }
  • Undocumented

    Declaration

    Swift

    public var uInt8: UInt8? { get set }
  • Undocumented

    Declaration

    Swift

    public var uInt8Value: UInt8 { get set }
  • Undocumented

    Declaration

    Swift

    public var int16: Int16? { get set }
  • Undocumented

    Declaration

    Swift

    public var int16Value: Int16 { get set }
  • Undocumented

    Declaration

    Swift

    public var uInt16: UInt16? { get set }
  • Undocumented

    Declaration

    Swift

    public var uInt16Value: UInt16 { get set }
  • Undocumented

    Declaration

    Swift

    public var int32: Int32? { get set }
  • Undocumented

    Declaration

    Swift

    public var int32Value: Int32 { get set }
  • Undocumented

    Declaration

    Swift

    public var uInt32: UInt32? { get set }
  • Undocumented

    Declaration

    Swift

    public var uInt32Value: UInt32 { get set }
  • Undocumented

    Declaration

    Swift

    public var int64: Int64? { get set }
  • Undocumented

    Declaration

    Swift

    public var int64Value: Int64 { get set }
  • Undocumented

    Declaration

    Swift

    public var uInt64: UInt64? { get set }
  • Undocumented

    Declaration

    Swift

    public var uInt64Value: UInt64 { get set }