0001    //  SwiftyJSON.swift
0002    //
0003    //  Copyright (c) 2014 Ruoyu Fu, Pinglin Tang
0004    //
0005    //  Permission is hereby granted, free of charge, to any person obtaining a copy
0006    //  of this software and associated documentation files (the "Software"), to deal
0007    //  in the Software without restriction, including without limitation the rights
0008    //  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
0009    //  copies of the Software, and to permit persons to whom the Software is
0010    //  furnished to do so, subject to the following conditions:
0011    //
0012    //  The above copyright notice and this permission notice shall be included in
0013    //  all copies or substantial portions of the Software.
0014    //
0015    //  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0016    //  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0017    //  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
0018    //  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
0019    //  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
0020    //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
0021    //  THE SOFTWARE.
0022    
0023    import Foundation
0024    
0025    // MARK: - Error
0026    
0027    ///Error domain
0028    public let ErrorDomain
SwiftyJSON.swift:180
                _error = NSError(domain: ErrorDomain, code: ErrorUnsupportedType, userInfo: [NSLocalizedDescriptionKey: "It is a unsupported type"])
SwiftyJSON.swift:448
                r._error = self._error ?? NSError(domain: ErrorDomain, code: ErrorWrongType, userInfo: [NSLocalizedDescriptionKey: "Array[\(index)] failure, It is not an array"])
SwiftyJSON.swift:454
                r._error = NSError(domain: ErrorDomain, code:ErrorIndexOutOfBounds , userInfo: [NSLocalizedDescriptionKey: "Array[\(index)] is out of bounds"])
SwiftyJSON.swift:475
                    r._error = NSError(domain: ErrorDomain, code: ErrorNotExist, userInfo: [NSLocalizedDescriptionKey: "Dictionary[\"\(key)\"] does not exist"])
SwiftyJSON.swift:478
                r._error = self._error ?? NSError(domain: ErrorDomain, code: ErrorWrongType, userInfo: [NSLocalizedDescriptionKey: "Dictionary[\"\(key)\"] failure, It is not an dictionary"])
SwiftyJSON.swift:639
            throw NSError(domain: ErrorDomain, code: ErrorInvalidJSON, userInfo: [NSLocalizedDescriptionKey: "JSON is invalid"])
: String = "SwiftyJSONErrorDomain" 0029 0030 ///Error code 0031 public let ErrorUnsupportedType
SwiftyJSON.swift:180
                _error = NSError(domain: ErrorDomain, code: ErrorUnsupportedType, userInfo: [NSLocalizedDescriptionKey: "It is a unsupported type"])
: Int = 999 0032 public let ErrorIndexOutOfBounds
SwiftyJSON.swift:454
                r._error = NSError(domain: ErrorDomain, code:ErrorIndexOutOfBounds , userInfo: [NSLocalizedDescriptionKey: "Array[\(index)] is out of bounds"])
: Int = 900 0033 public let ErrorWrongType
SwiftyJSON.swift:448
                r._error = self._error ?? NSError(domain: ErrorDomain, code: ErrorWrongType, userInfo: [NSLocalizedDescriptionKey: "Array[\(index)] failure, It is not an array"])
SwiftyJSON.swift:478
                r._error = self._error ?? NSError(domain: ErrorDomain, code: ErrorWrongType, userInfo: [NSLocalizedDescriptionKey: "Dictionary[\"\(key)\"] failure, It is not an dictionary"])
: Int = 901 0034 public let ErrorNotExist
SwiftyJSON.swift:475
                    r._error = NSError(domain: ErrorDomain, code: ErrorNotExist, userInfo: [NSLocalizedDescriptionKey: "Dictionary[\"\(key)\"] does not exist"])
SwiftyJSON.swift:908
        if let errorValue = error where errorValue.code == ErrorNotExist{
: Int = 500 0035 public let ErrorInvalidJSON
SwiftyJSON.swift:639
            throw NSError(domain: ErrorDomain, code: ErrorInvalidJSON, userInfo: [NSLocalizedDescriptionKey: "JSON is invalid"])
: Int = 490 0036 0037 // MARK: - JSON Type 0038 0039 /** 0040 JSON's type definitions. 0041 0042 See http://www.json.org 0043 */ 0044 public enum Type
SwiftyJSON.swift:135
    private var _type: Type = .Null
SwiftyJSON.swift:186
    public var type: Type { get { return _type } }
SwiftyJSON.swift:290
    let type: Type
SwiftyJSON.swift:381
    private let type: Type
:Int{ 0045 0046 case Number
SwiftyJSON.swift:149
            case .Number:
SwiftyJSON.swift:164
                    _type = .Number
SwiftyJSON.swift:656
        case .Number:
SwiftyJSON.swift:796
            case .Bool, .Number, .String:
SwiftyJSON.swift:837
            case .Number:
SwiftyJSON.swift:858
            case .Number, .Bool:
SwiftyJSON.swift:879
            case .Number, .Bool:
SwiftyJSON.swift:1213
    case (.Number, .Number):
SwiftyJSON.swift:1213
    case (.Number, .Number):
SwiftyJSON.swift:1233
    case (.Number, .Number):
SwiftyJSON.swift:1233
    case (.Number, .Number):
SwiftyJSON.swift:1253
    case (.Number, .Number):
SwiftyJSON.swift:1253
    case (.Number, .Number):
SwiftyJSON.swift:1273
    case (.Number, .Number):
SwiftyJSON.swift:1273
    case (.Number, .Number):
SwiftyJSON.swift:1285
    case (.Number, .Number):
SwiftyJSON.swift:1285
    case (.Number, .Number):
0047 case String
SwiftyJSON.swift:147
            case .String:
SwiftyJSON.swift:168
                _type = .String
SwiftyJSON.swift:654
        case .String:
SwiftyJSON.swift:796
            case .Bool, .Number, .String:
SwiftyJSON.swift:816
            case .String:
SwiftyJSON.swift:835
            case .String:
SwiftyJSON.swift:873
            case .String:
SwiftyJSON.swift:922
            case .String:
SwiftyJSON.swift:1215
    case (.String, .String):
SwiftyJSON.swift:1215
    case (.String, .String):
SwiftyJSON.swift:1235
    case (.String, .String):
SwiftyJSON.swift:1235
    case (.String, .String):
SwiftyJSON.swift:1255
    case (.String, .String):
SwiftyJSON.swift:1255
    case (.String, .String):
SwiftyJSON.swift:1275
    case (.String, .String):
SwiftyJSON.swift:1275
    case (.String, .String):
SwiftyJSON.swift:1287
    case (.String, .String):
SwiftyJSON.swift:1287
    case (.String, .String):
0048 case Bool
SwiftyJSON.swift:151
            case .Bool:
SwiftyJSON.swift:162
                    _type = .Bool
SwiftyJSON.swift:658
        case .Bool:
SwiftyJSON.swift:777
            case .Bool:
SwiftyJSON.swift:796
            case .Bool, .Number, .String:
SwiftyJSON.swift:839
            case .Bool:
SwiftyJSON.swift:858
            case .Number, .Bool:
SwiftyJSON.swift:879
            case .Number, .Bool:
SwiftyJSON.swift:1217
    case (.Bool, .Bool):
SwiftyJSON.swift:1217
    case (.Bool, .Bool):
SwiftyJSON.swift:1237
    case (.Bool, .Bool):
SwiftyJSON.swift:1237
    case (.Bool, .Bool):
SwiftyJSON.swift:1257
    case (.Bool, .Bool):
SwiftyJSON.swift:1257
    case (.Bool, .Bool):
0049 case Array
SwiftyJSON.swift:143
            case .Array:
SwiftyJSON.swift:173
                _type = .Array
SwiftyJSON.swift:206
        case .Array:
SwiftyJSON.swift:217
        case .Array:
SwiftyJSON.swift:228
        case .Array:
SwiftyJSON.swift:242
            case .Array:
SwiftyJSON.swift:255
        case .Array:
SwiftyJSON.swift:266
        case .Array:
SwiftyJSON.swift:301
        self.type = .Array
SwiftyJSON.swift:312
        case .Array:
SwiftyJSON.swift:324
    case (.Array, .Array):
SwiftyJSON.swift:324
    case (.Array, .Array):
SwiftyJSON.swift:335
    case (.Array, .Array):
SwiftyJSON.swift:335
    case (.Array, .Array):
SwiftyJSON.swift:346
    case (.Array, .Array):
SwiftyJSON.swift:346
    case (.Array, .Array):
SwiftyJSON.swift:357
    case (.Array, .Array):
SwiftyJSON.swift:357
    case (.Array, .Array):
SwiftyJSON.swift:368
    case (.Array, .Array):
SwiftyJSON.swift:368
    case (.Array, .Array):
SwiftyJSON.swift:388
        if type == .Array {
SwiftyJSON.swift:397
        case .Array:
SwiftyJSON.swift:446
            if self.type != .Array {
SwiftyJSON.swift:459
            if self.type == .Array {
SwiftyJSON.swift:647
        case .Array, .Dictionary:
SwiftyJSON.swift:692
            if self.type == .Array {
SwiftyJSON.swift:711
            case .Array:
SwiftyJSON.swift:1219
    case (.Array, .Array):
SwiftyJSON.swift:1219
    case (.Array, .Array):
SwiftyJSON.swift:1239
    case (.Array, .Array):
SwiftyJSON.swift:1239
    case (.Array, .Array):
SwiftyJSON.swift:1259
    case (.Array, .Array):
SwiftyJSON.swift:1259
    case (.Array, .Array):
0050 case Dictionary
SwiftyJSON.swift:145
            case .Dictionary:
SwiftyJSON.swift:176
                _type = .Dictionary
SwiftyJSON.swift:208
        case .Dictionary:
SwiftyJSON.swift:219
        case .Dictionary:
SwiftyJSON.swift:230
        case .Dictionary:
SwiftyJSON.swift:244
            case .Dictionary:
SwiftyJSON.swift:257
        case .Dictionary:
SwiftyJSON.swift:268
        case .Dictionary:
SwiftyJSON.swift:307
        self.type = .Dictionary
SwiftyJSON.swift:314
        case .Dictionary:
SwiftyJSON.swift:326
    case (.Dictionary, .Dictionary):
SwiftyJSON.swift:326
    case (.Dictionary, .Dictionary):
SwiftyJSON.swift:337
    case (.Dictionary, .Dictionary):
SwiftyJSON.swift:337
    case (.Dictionary, .Dictionary):
SwiftyJSON.swift:348
    case (.Dictionary, .Dictionary):
SwiftyJSON.swift:348
    case (.Dictionary, .Dictionary):
SwiftyJSON.swift:359
    case (.Dictionary, .Dictionary):
SwiftyJSON.swift:359
    case (.Dictionary, .Dictionary):
SwiftyJSON.swift:370
    case (.Dictionary, .Dictionary):
SwiftyJSON.swift:370
    case (.Dictionary, .Dictionary):
SwiftyJSON.swift:403
        case .Dictionary:
SwiftyJSON.swift:471
            if self.type == .Dictionary {
SwiftyJSON.swift:483
            if self.type == .Dictionary && newValue.error == nil {
SwiftyJSON.swift:647
        case .Array, .Dictionary:
SwiftyJSON.swift:733
        if self.type == .Dictionary {
SwiftyJSON.swift:753
            case .Dictionary:
SwiftyJSON.swift:1221
    case (.Dictionary, .Dictionary):
SwiftyJSON.swift:1221
    case (.Dictionary, .Dictionary):
SwiftyJSON.swift:1241
    case (.Dictionary, .Dictionary):
SwiftyJSON.swift:1241
    case (.Dictionary, .Dictionary):
SwiftyJSON.swift:1261
    case (.Dictionary, .Dictionary):
SwiftyJSON.swift:1261
    case (.Dictionary, .Dictionary):
0051 case Null
SwiftyJSON.swift:135
    private var _type: Type = .Null
SwiftyJSON.swift:171
                _type = .Null
SwiftyJSON.swift:660
        case .Null:
SwiftyJSON.swift:897
            case .Null:
SwiftyJSON.swift:1223
    case (.Null, .Null):
SwiftyJSON.swift:1223
    case (.Null, .Null):
SwiftyJSON.swift:1243
    case (.Null, .Null):
SwiftyJSON.swift:1243
    case (.Null, .Null):
SwiftyJSON.swift:1263
    case (.Null, .Null):
SwiftyJSON.swift:1263
    case (.Null, .Null):
0052 case Unknown
SwiftyJSON.swift:179
                _type = .Unknown
SwiftyJSON.swift:295
        self.type = .Unknown
SwiftyJSON.swift:626
        if JSON(rawValue).type == .Unknown {
0053 } 0054 0055 // MARK: - JSON Base 0056 0057 public struct JSON
SwiftyJSON.swift:86
    public static func parse(string:String) -> JSON {
SwiftyJSON.swift:88
            .flatMap({JSON(data: $0)}) ?? JSON(NSNull())
SwiftyJSON.swift:88
            .flatMap({JSON(data: $0)}) ?? JSON(NSNull())
SwiftyJSON.swift:109
    public init(_ jsonArray:[JSON]) {
SwiftyJSON.swift:120
    public init(_ jsonDictionary:[String: JSON]) {
SwiftyJSON.swift:193
    public static var nullJSON: JSON { get { return null } }
SwiftyJSON.swift:194
    public static var null: JSON { get { return JSON(NSNull()) } }
SwiftyJSON.swift:194
    public static var null: JSON { get { return JSON(NSNull()) } }
SwiftyJSON.swift:198
extension JSON : Swift.CollectionType, Swift.SequenceType, Swift.Indexable {
SwiftyJSON.swift:204
    public var startIndex: JSON.Index {
SwiftyJSON.swift:215
    public var endIndex: JSON.Index {
SwiftyJSON.swift:229
            return (String(position.arrayIndex), JSON(self.rawArray[position.arrayIndex!]))
SwiftyJSON.swift:232
            return (key, JSON(value))
SwiftyJSON.swift:234
            return ("", JSON.null)
SwiftyJSON.swift:280
    public func generate() -> JSON.Generator {
SwiftyJSON.swift:281
        return JSON.Generator(self)
SwiftyJSON.swift:379
    public typealias Element = (String, JSON)
SwiftyJSON.swift:386
    init(_ json: JSON) {
SwiftyJSON.swift:399
                return (String(self.arrayIndex++), JSON(o))
SwiftyJSON.swift:405
                return (k, JSON(v))
SwiftyJSON.swift:441
extension JSON {
SwiftyJSON.swift:447
                var r = JSON.null
SwiftyJSON.swift:451
                return JSON(self.rawArray[index])
SwiftyJSON.swift:453
                var r = JSON.null
SwiftyJSON.swift:470
            var r = JSON.null
SwiftyJSON.swift:473
                    r = JSON(o)
SwiftyJSON.swift:560
extension JSON: Swift.StringLiteralConvertible {
SwiftyJSON.swift:575
extension JSON: Swift.IntegerLiteralConvertible {
SwiftyJSON.swift:582
extension JSON: Swift.BooleanLiteralConvertible {
SwiftyJSON.swift:589
extension JSON: Swift.FloatLiteralConvertible {
SwiftyJSON.swift:596
extension JSON: Swift.DictionaryLiteralConvertible {
SwiftyJSON.swift:607
extension JSON: Swift.ArrayLiteralConvertible {
SwiftyJSON.swift:614
extension JSON: Swift.NilLiteralConvertible {
SwiftyJSON.swift:623
extension JSON: Swift.RawRepresentable {
SwiftyJSON.swift:626
        if JSON(rawValue).type == .Unknown {
SwiftyJSON.swift:670
extension JSON: Swift.Printable, Swift.DebugPrintable {
SwiftyJSON.swift:687
extension JSON {
SwiftyJSON.swift:693
                return self.rawArray.map{ JSON($0) }
SwiftyJSON.swift:690
    public var array: [JSON]? {
SwiftyJSON.swift:701
    public var arrayValue: [JSON] {
SwiftyJSON.swift:729
extension JSON {
SwiftyJSON.swift:734
            return self.rawDictionary.reduce([String : JSON]()) { (dictionary: [String : JSON], element: (String, AnyObject)) -> [String : JSON] in
SwiftyJSON.swift:734
            return self.rawDictionary.reduce([String : JSON]()) { (dictionary: [String : JSON], element: (String, AnyObject)) -> [String : JSON] in
SwiftyJSON.swift:734
            return self.rawDictionary.reduce([String : JSON]()) { (dictionary: [String : JSON], element: (String, AnyObject)) -> [String : JSON] in
SwiftyJSON.swift:736
                d[element.0] = JSON(element.1)
SwiftyJSON.swift:732
    public var dictionary: [String : JSON]? {
SwiftyJSON.swift:745
    public var dictionaryValue: [String : JSON] {
SwiftyJSON.swift:771
extension JSON: Swift.BooleanType {
SwiftyJSON.swift:810
extension JSON {
SwiftyJSON.swift:852
extension JSON {
SwiftyJSON.swift:892
extension JSON {
SwiftyJSON.swift:916
extension JSON {
SwiftyJSON.swift:940
extension JSON {
SwiftyJSON.swift:1208
extension JSON : Swift.Comparable {}
SwiftyJSON.swift:1210
public func ==(lhs: JSON, rhs: JSON) -> Bool {
SwiftyJSON.swift:1210
public func ==(lhs: JSON, rhs: JSON) -> Bool {
SwiftyJSON.swift:1230
public func <=(lhs: JSON, rhs: JSON) -> Bool {
SwiftyJSON.swift:1230
public func <=(lhs: JSON, rhs: JSON) -> Bool {
SwiftyJSON.swift:1250
public func >=(lhs: JSON, rhs: JSON) -> Bool {
SwiftyJSON.swift:1250
public func >=(lhs: JSON, rhs: JSON) -> Bool {
SwiftyJSON.swift:1270
public func >(lhs: JSON, rhs: JSON) -> Bool {
SwiftyJSON.swift:1270
public func >(lhs: JSON, rhs: JSON) -> Bool {
SwiftyJSON.swift:1282
public func <(lhs: JSON, rhs: JSON) -> Bool {
SwiftyJSON.swift:1282
public func <(lhs: JSON, rhs: JSON) -> Bool {
{ 0058 0059 /** 0060 Creates a JSON using the data. 0061 0062 - parameter data: The NSData used to convert to json.Top level object in data is an NSArray or NSDictionary 0063 - parameter opt: The JSON serialization reading options. `.AllowFragments` by default. 0064 - parameter error: error The NSErrorPointer used to return the error. `nil` by default. 0065 0066 - returns: The created JSON 0067 */ 0068 public init
SwiftyJSON.swift:88
            .flatMap({JSON(data: $0)}) ?? JSON(NSNull())
(data:NSData, options opt: NSJSONReadingOptions = .AllowFragments, error: NSErrorPointer = nil) { 0069 do { 0070 let object: AnyObject = try NSJSONSerialization.JSONObjectWithData(data, options: opt) 0071 self.init(object) 0072 } catch let aError as NSError { 0073 if error != nil { 0074 error.memory = aError 0075 } 0076 self.init(NSNull()) 0077 } 0078 } 0079 0080 /** 0081 Create a JSON from JSON string 0082 - parameter string: Normal json string like '{"a":"b"}' 0083 0084 - returns: The created JSON 0085 */ 0086 public static func parse(string:String) -> JSON { 0087 return string.dataUsingEncoding(NSUTF8StringEncoding) 0088 .flatMap({JSON(data: $0)}) ?? JSON(NSNull()) 0089 } 0090 0091 /** 0092 Creates a JSON using the object. 0093 0094 - parameter 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. 0095 0096 - returns: The created JSON 0097 */ 0098 public init
SwiftyJSON.swift:71
            self.init(object)
SwiftyJSON.swift:76
            self.init(NSNull())
SwiftyJSON.swift:88
            .flatMap({JSON(data: $0)}) ?? JSON(NSNull())
SwiftyJSON.swift:110
        self.init(jsonArray.map { $0.object })
SwiftyJSON.swift:125
        self.init(dictionary)
SwiftyJSON.swift:194
    public static var null: JSON { get { return JSON(NSNull()) } }
SwiftyJSON.swift:229
            return (String(position.arrayIndex), JSON(self.rawArray[position.arrayIndex!]))
SwiftyJSON.swift:232
            return (key, JSON(value))
SwiftyJSON.swift:399
                return (String(self.arrayIndex++), JSON(o))
SwiftyJSON.swift:405
                return (k, JSON(v))
SwiftyJSON.swift:451
                return JSON(self.rawArray[index])
SwiftyJSON.swift:473
                    r = JSON(o)
SwiftyJSON.swift:563
        self.init(value)
SwiftyJSON.swift:567
        self.init(value)
SwiftyJSON.swift:571
        self.init(value)
SwiftyJSON.swift:578
        self.init(value)
SwiftyJSON.swift:585
        self.init(value)
SwiftyJSON.swift:592
        self.init(value)
SwiftyJSON.swift:599
        self.init(elements.reduce([String : AnyObject]()){(dictionary: [String : AnyObject], element:(String, AnyObject)) -> [String : AnyObject] in
SwiftyJSON.swift:610
        self.init(elements)
SwiftyJSON.swift:617
        self.init(NSNull())
SwiftyJSON.swift:626
        if JSON(rawValue).type == .Unknown {
SwiftyJSON.swift:629
            self.init(rawValue)
SwiftyJSON.swift:693
                return self.rawArray.map{ JSON($0) }
SwiftyJSON.swift:736
                d[element.0] = JSON(element.1)
(_ object: AnyObject) { 0099 self.object = object 0100 } 0101 0102 /** 0103 Creates a JSON from a [JSON] 0104 0105 - parameter jsonArray: A Swift array of JSON objects 0106 0107 - returns: The created JSON 0108 */ 0109 public init(_ jsonArray:[JSON]) { 0110 self.init(jsonArray.map { $0.object }) 0111 } 0112 0113 /** 0114 Creates a JSON from a [String: JSON] 0115 0116 - parameter jsonDictionary: A Swift dictionary of JSON objects 0117 0118 - returns: The created JSON 0119 */ 0120 public init(_ jsonDictionary:[String: JSON]) { 0121 var dictionary = [String: AnyObject]() 0122 for (key, json) in jsonDictionary { 0123 dictionary[key] = json.object 0124 } 0125 self.init(dictionary) 0126 } 0127 0128 /// Private object 0129 private var rawArray
SwiftyJSON.swift:144
                return self.rawArray
SwiftyJSON.swift:174
                self.rawArray = array
SwiftyJSON.swift:207
            return JSONIndex(arrayIndex: self.rawArray.startIndex)
SwiftyJSON.swift:218
            return JSONIndex(arrayIndex: self.rawArray.endIndex)
SwiftyJSON.swift:229
            return (String(position.arrayIndex), JSON(self.rawArray[position.arrayIndex!]))
SwiftyJSON.swift:243
                return self.rawArray.isEmpty
SwiftyJSON.swift:256
            return self.rawArray.count
SwiftyJSON.swift:267
            return self.rawArray.underestimateCount()
SwiftyJSON.swift:389
            self.arrayGenerate = json.rawArray.generate()
SwiftyJSON.swift:450
            } else if index >= 0 && index < self.rawArray.count {
SwiftyJSON.swift:451
                return JSON(self.rawArray[index])
SwiftyJSON.swift:460
                if self.rawArray.count > index && newValue.error == nil {
SwiftyJSON.swift:461
                    self.rawArray[index] = newValue.object
SwiftyJSON.swift:693
                return self.rawArray.map{ JSON($0) }
SwiftyJSON.swift:712
                return self.rawArray
SwiftyJSON.swift:1220
        return lhs.rawArray as NSArray == rhs.rawArray as NSArray
SwiftyJSON.swift:1220
        return lhs.rawArray as NSArray == rhs.rawArray as NSArray
SwiftyJSON.swift:1240
        return lhs.rawArray as NSArray == rhs.rawArray as NSArray
SwiftyJSON.swift:1240
        return lhs.rawArray as NSArray == rhs.rawArray as NSArray
SwiftyJSON.swift:1260
        return lhs.rawArray as NSArray == rhs.rawArray as NSArray
SwiftyJSON.swift:1260
        return lhs.rawArray as NSArray == rhs.rawArray as NSArray
: [AnyObject] = [] 0130 private var rawDictionary
SwiftyJSON.swift:146
                return self.rawDictionary
SwiftyJSON.swift:177
                self.rawDictionary = dictionary
SwiftyJSON.swift:209
            return JSONIndex(dictionaryIndex: self.rawDictionary.startIndex)
SwiftyJSON.swift:220
            return JSONIndex(dictionaryIndex: self.rawDictionary.endIndex)
SwiftyJSON.swift:231
            let (key, value) = self.rawDictionary[position.dictionaryIndex!]
SwiftyJSON.swift:245
                return self.rawDictionary.isEmpty
SwiftyJSON.swift:258
            return self.rawDictionary.count
SwiftyJSON.swift:269
            return self.rawDictionary.underestimateCount()
SwiftyJSON.swift:391
            self.dictionayGenerate = json.rawDictionary.generate()
SwiftyJSON.swift:472
                if let o = self.rawDictionary[key] {
SwiftyJSON.swift:484
                self.rawDictionary[key] = newValue.object
SwiftyJSON.swift:734
            return self.rawDictionary.reduce([String : JSON]()) { (dictionary: [String : JSON], element: (String, AnyObject)) -> [String : JSON] in
SwiftyJSON.swift:754
                return self.rawDictionary
SwiftyJSON.swift:1222
        return lhs.rawDictionary as NSDictionary == rhs.rawDictionary as NSDictionary
SwiftyJSON.swift:1222
        return lhs.rawDictionary as NSDictionary == rhs.rawDictionary as NSDictionary
SwiftyJSON.swift:1242
        return lhs.rawDictionary as NSDictionary == rhs.rawDictionary as NSDictionary
SwiftyJSON.swift:1242
        return lhs.rawDictionary as NSDictionary == rhs.rawDictionary as NSDictionary
SwiftyJSON.swift:1262
        return lhs.rawDictionary as NSDictionary == rhs.rawDictionary as NSDictionary
SwiftyJSON.swift:1262
        return lhs.rawDictionary as NSDictionary == rhs.rawDictionary as NSDictionary
: [String : AnyObject] = [:] 0131 private var rawString
SwiftyJSON.swift:148
                return self.rawString
SwiftyJSON.swift:169
                self.rawString = string
SwiftyJSON.swift:655
            return self.rawString
SwiftyJSON.swift:923
                if let encodedString_ = self.rawString.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet()) {
SwiftyJSON.swift:1216
        return lhs.rawString == rhs.rawString
SwiftyJSON.swift:1216
        return lhs.rawString == rhs.rawString
SwiftyJSON.swift:1236
        return lhs.rawString <= rhs.rawString
SwiftyJSON.swift:1236
        return lhs.rawString <= rhs.rawString
SwiftyJSON.swift:1256
        return lhs.rawString >= rhs.rawString
SwiftyJSON.swift:1256
        return lhs.rawString >= rhs.rawString
SwiftyJSON.swift:1276
        return lhs.rawString > rhs.rawString
SwiftyJSON.swift:1276
        return lhs.rawString > rhs.rawString
SwiftyJSON.swift:1288
        return lhs.rawString < rhs.rawString
SwiftyJSON.swift:1288
        return lhs.rawString < rhs.rawString
: String = "" 0132 private var rawNumber
SwiftyJSON.swift:150
                return self.rawNumber
SwiftyJSON.swift:152
                return self.rawNumber
SwiftyJSON.swift:166
                self.rawNumber = number
SwiftyJSON.swift:657
            return self.rawNumber.stringValue
SwiftyJSON.swift:659
            return self.rawNumber.boolValue.description
SwiftyJSON.swift:778
                return self.rawNumber.boolValue
SwiftyJSON.swift:859
                return self.rawNumber
SwiftyJSON.swift:1214
        return lhs.rawNumber == rhs.rawNumber
SwiftyJSON.swift:1214
        return lhs.rawNumber == rhs.rawNumber
SwiftyJSON.swift:1218
        return lhs.rawNumber.boolValue == rhs.rawNumber.boolValue
SwiftyJSON.swift:1218
        return lhs.rawNumber.boolValue == rhs.rawNumber.boolValue
SwiftyJSON.swift:1234
        return lhs.rawNumber <= rhs.rawNumber
SwiftyJSON.swift:1234
        return lhs.rawNumber <= rhs.rawNumber
SwiftyJSON.swift:1238
        return lhs.rawNumber.boolValue == rhs.rawNumber.boolValue
SwiftyJSON.swift:1238
        return lhs.rawNumber.boolValue == rhs.rawNumber.boolValue
SwiftyJSON.swift:1254
        return lhs.rawNumber >= rhs.rawNumber
SwiftyJSON.swift:1254
        return lhs.rawNumber >= rhs.rawNumber
SwiftyJSON.swift:1258
        return lhs.rawNumber.boolValue == rhs.rawNumber.boolValue
SwiftyJSON.swift:1258
        return lhs.rawNumber.boolValue == rhs.rawNumber.boolValue
SwiftyJSON.swift:1274
        return lhs.rawNumber > rhs.rawNumber
SwiftyJSON.swift:1274
        return lhs.rawNumber > rhs.rawNumber
SwiftyJSON.swift:1286
        return lhs.rawNumber < rhs.rawNumber
SwiftyJSON.swift:1286
        return lhs.rawNumber < rhs.rawNumber
: NSNumber = 0 0133 private var rawNull
SwiftyJSON.swift:154
                return self.rawNull
SwiftyJSON.swift:898
                return self.rawNull
: NSNull = NSNull() 0134 /// Private type 0135 private var _type
SwiftyJSON.swift:162
                    _type = .Bool
SwiftyJSON.swift:164
                    _type = .Number
SwiftyJSON.swift:168
                _type = .String
SwiftyJSON.swift:171
                _type = .Null
SwiftyJSON.swift:173
                _type = .Array
SwiftyJSON.swift:176
                _type = .Dictionary
SwiftyJSON.swift:179
                _type = .Unknown
SwiftyJSON.swift:186
    public var type: Type { get { return _type } }
: Type = .Null 0136 /// prviate error 0137 private var _error
SwiftyJSON.swift:158
            _error = nil
SwiftyJSON.swift:180
                _error = NSError(domain: ErrorDomain, code: ErrorUnsupportedType, userInfo: [NSLocalizedDescriptionKey: "It is a unsupported type"])
SwiftyJSON.swift:189
    public var error: NSError? { get { return self._error } }
SwiftyJSON.swift:448
                r._error = self._error ?? NSError(domain: ErrorDomain, code: ErrorWrongType, userInfo: [NSLocalizedDescriptionKey: "Array[\(index)] failure, It is not an array"])
SwiftyJSON.swift:448
                r._error = self._error ?? NSError(domain: ErrorDomain, code: ErrorWrongType, userInfo: [NSLocalizedDescriptionKey: "Array[\(index)] failure, It is not an array"])
SwiftyJSON.swift:454
                r._error = NSError(domain: ErrorDomain, code:ErrorIndexOutOfBounds , userInfo: [NSLocalizedDescriptionKey: "Array[\(index)] is out of bounds"])
SwiftyJSON.swift:475
                    r._error = NSError(domain: ErrorDomain, code: ErrorNotExist, userInfo: [NSLocalizedDescriptionKey: "Dictionary[\"\(key)\"] does not exist"])
SwiftyJSON.swift:478
                r._error = self._error ?? NSError(domain: ErrorDomain, code: ErrorWrongType, userInfo: [NSLocalizedDescriptionKey: "Dictionary[\"\(key)\"] failure, It is not an dictionary"])
SwiftyJSON.swift:478
                r._error = self._error ?? NSError(domain: ErrorDomain, code: ErrorWrongType, userInfo: [NSLocalizedDescriptionKey: "Dictionary[\"\(key)\"] failure, It is not an dictionary"])
: NSError? = nil 0138 0139 /// Object in JSON 0140 public var object
SwiftyJSON.swift:99
        self.object = object
SwiftyJSON.swift:110
        self.init(jsonArray.map { $0.object })
SwiftyJSON.swift:123
            dictionary[key] = json.object
SwiftyJSON.swift:461
                    self.rawArray[index] = newValue.object
SwiftyJSON.swift:484
                self.rawDictionary[key] = newValue.object
SwiftyJSON.swift:527
                self[sub:path[0]].object = newValue.object
SwiftyJSON.swift:527
                self[sub:path[0]].object = newValue.object
SwiftyJSON.swift:634
        return self.object
SwiftyJSON.swift:638
        guard NSJSONSerialization.isValidJSONObject(self.object) else {
SwiftyJSON.swift:642
        return try NSJSONSerialization.dataWithJSONObject(self.object, options: opt)
SwiftyJSON.swift:719
                self.object = array
SwiftyJSON.swift:721
                self.object = NSNull()
SwiftyJSON.swift:761
                self.object = v
SwiftyJSON.swift:763
                self.object = NSNull()
SwiftyJSON.swift:785
                self.object = NSNumber(bool: newValue)
SwiftyJSON.swift:787
                self.object = NSNull()
SwiftyJSON.swift:797
                return self.object.boolValue
SwiftyJSON.swift:803
            self.object = NSNumber(bool: newValue)
SwiftyJSON.swift:817
                return self.object as? String
SwiftyJSON.swift:824
                self.object = NSString(string:newValue)
SwiftyJSON.swift:826
                self.object = NSNull()
SwiftyJSON.swift:836
                return self.object as? String ?? ""
SwiftyJSON.swift:838
                return self.object.stringValue
SwiftyJSON.swift:840
                return (self.object as? Bool).map { String($0) } ?? ""
SwiftyJSON.swift:846
            self.object = NSString(string:newValue)
SwiftyJSON.swift:865
            self.object = newValue ?? NSNull()
SwiftyJSON.swift:874
                let decimal = NSDecimalNumber(string: self.object as? String)
SwiftyJSON.swift:880
                return self.object as? NSNumber ?? NSNumber(int: 0)
SwiftyJSON.swift:886
            self.object = newValue
SwiftyJSON.swift:904
            self.object = NSNull()
SwiftyJSON.swift:933
            self.object = newValue?.absoluteString ?? NSNull()
SwiftyJSON.swift:948
                self.object = NSNumber(double: newValue)
SwiftyJSON.swift:950
                self.object = NSNull()
SwiftyJSON.swift:960
            self.object = NSNumber(double: newValue)
SwiftyJSON.swift:970
                self.object = NSNumber(float: newValue)
SwiftyJSON.swift:972
                self.object = NSNull()
SwiftyJSON.swift:982
            self.object = NSNumber(float: newValue)
SwiftyJSON.swift:992
                self.object = NSNumber(integer: newValue)
SwiftyJSON.swift:994
                self.object = NSNull()
SwiftyJSON.swift:1004
            self.object = NSNumber(integer: newValue)
SwiftyJSON.swift:1014
                self.object = NSNumber(unsignedLong: newValue)
SwiftyJSON.swift:1016
                self.object = NSNull()
SwiftyJSON.swift:1026
            self.object = NSNumber(unsignedLong: newValue)
SwiftyJSON.swift:1036
                self.object = NSNumber(char: newValue)
SwiftyJSON.swift:1038
                self.object =  NSNull()
SwiftyJSON.swift:1048
            self.object = NSNumber(char: newValue)
SwiftyJSON.swift:1058
                self.object = NSNumber(unsignedChar: newValue)
SwiftyJSON.swift:1060
                self.object =  NSNull()
SwiftyJSON.swift:1070
            self.object = NSNumber(unsignedChar: newValue)
SwiftyJSON.swift:1080
                self.object = NSNumber(short: newValue)
SwiftyJSON.swift:1082
                self.object =  NSNull()
SwiftyJSON.swift:1092
            self.object = NSNumber(short: newValue)
SwiftyJSON.swift:1102
                self.object = NSNumber(unsignedShort: newValue)
SwiftyJSON.swift:1104
                self.object =  NSNull()
SwiftyJSON.swift:1114
            self.object = NSNumber(unsignedShort: newValue)
SwiftyJSON.swift:1124
                self.object = NSNumber(int: newValue)
SwiftyJSON.swift:1126
                self.object =  NSNull()
SwiftyJSON.swift:1136
            self.object = NSNumber(int: newValue)
SwiftyJSON.swift:1146
                self.object = NSNumber(unsignedInt: newValue)
SwiftyJSON.swift:1148
                self.object =  NSNull()
SwiftyJSON.swift:1158
            self.object = NSNumber(unsignedInt: newValue)
SwiftyJSON.swift:1168
                self.object = NSNumber(longLong: newValue)
SwiftyJSON.swift:1170
                self.object =  NSNull()
SwiftyJSON.swift:1180
            self.object = NSNumber(longLong: newValue)
SwiftyJSON.swift:1190
                self.object = NSNumber(unsignedLongLong: newValue)
SwiftyJSON.swift:1192
                self.object =  NSNull()
SwiftyJSON.swift:1202
            self.object = NSNumber(unsignedLongLong: newValue)
: AnyObject { 0141 get { 0142 switch self.type { 0143 case .Array: 0144 return self.rawArray 0145 case .Dictionary: 0146 return self.rawDictionary 0147 case .String: 0148 return self.rawString 0149 case .Number: 0150 return self.rawNumber 0151 case .Bool: 0152 return self.rawNumber 0153 default: 0154 return self.rawNull 0155 } 0156 } 0157 set { 0158 _error = nil 0159 switch newValue { 0160 case let number as NSNumber: 0161 if number.isBool { 0162 _type = .Bool 0163 } else { 0164 _type = .Number 0165 } 0166 self.rawNumber = number 0167 case let string as String: 0168 _type = .String 0169 self.rawString = string 0170 case _ as NSNull: 0171 _type = .Null 0172 case let array as [AnyObject]: 0173 _type = .Array 0174 self.rawArray = array 0175 case let dictionary as [String : AnyObject]: 0176 _type = .Dictionary 0177 self.rawDictionary = dictionary 0178 default: 0179 _type = .Unknown 0180 _error = NSError(domain: ErrorDomain, code: ErrorUnsupportedType, userInfo: [NSLocalizedDescriptionKey: "It is a unsupported type"]) 0181 } 0182 } 0183 } 0184 0185 /// json type 0186 public var type
SwiftyJSON.swift:142
            switch self.type {
SwiftyJSON.swift:205
        switch self.type {
SwiftyJSON.swift:216
        switch self.type {
SwiftyJSON.swift:227
        switch self.type {
SwiftyJSON.swift:241
            switch self.type {
SwiftyJSON.swift:254
        switch self.type {
SwiftyJSON.swift:265
        switch self.type {
SwiftyJSON.swift:387
        self.type = json.type
SwiftyJSON.swift:446
            if self.type != .Array {
SwiftyJSON.swift:459
            if self.type == .Array {
SwiftyJSON.swift:471
            if self.type == .Dictionary {
SwiftyJSON.swift:483
            if self.type == .Dictionary && newValue.error == nil {
SwiftyJSON.swift:626
        if JSON(rawValue).type == .Unknown {
SwiftyJSON.swift:646
        switch self.type {
SwiftyJSON.swift:692
            if self.type == .Array {
SwiftyJSON.swift:710
            switch self.type {
SwiftyJSON.swift:733
        if self.type == .Dictionary {
SwiftyJSON.swift:752
            switch self.type {
SwiftyJSON.swift:776
            switch self.type {
SwiftyJSON.swift:795
            switch self.type {
SwiftyJSON.swift:815
            switch self.type {
SwiftyJSON.swift:834
            switch self.type {
SwiftyJSON.swift:857
            switch self.type {
SwiftyJSON.swift:872
            switch self.type {
SwiftyJSON.swift:896
            switch self.type {
SwiftyJSON.swift:921
            switch self.type {
SwiftyJSON.swift:1212
    switch (lhs.type, rhs.type) {
SwiftyJSON.swift:1212
    switch (lhs.type, rhs.type) {
SwiftyJSON.swift:1232
    switch (lhs.type, rhs.type) {
SwiftyJSON.swift:1232
    switch (lhs.type, rhs.type) {
SwiftyJSON.swift:1252
    switch (lhs.type, rhs.type) {
SwiftyJSON.swift:1252
    switch (lhs.type, rhs.type) {
SwiftyJSON.swift:1272
    switch (lhs.type, rhs.type) {
SwiftyJSON.swift:1272
    switch (lhs.type, rhs.type) {
SwiftyJSON.swift:1284
    switch (lhs.type, rhs.type) {
SwiftyJSON.swift:1284
    switch (lhs.type, rhs.type) {
: Type { get { return _type } } 0187 0188 /// Error in JSON 0189 public var error
SwiftyJSON.swift:460
                if self.rawArray.count > index && newValue.error == nil {
SwiftyJSON.swift:483
            if self.type == .Dictionary && newValue.error == nil {
SwiftyJSON.swift:908
        if let errorValue = error where errorValue.code == ErrorNotExist{
: NSError? { get { return self._error } } 0190 0191 /// The static null json 0192 @available(*, unavailable, renamed="null") 0193 public static var nullJSON: JSON { get { return null } } 0194 public static var null
SwiftyJSON.swift:234
            return ("", JSON.null)
SwiftyJSON.swift:447
                var r = JSON.null
SwiftyJSON.swift:453
                var r = JSON.null
SwiftyJSON.swift:470
            var r = JSON.null
: JSON { get { return JSON(NSNull()) } } 0195 } 0196 0197 // MARK: - CollectionType, SequenceType, Indexable 0198 extension JSON : Swift.CollectionType, Swift.SequenceType, Swift.Indexable { 0199 0200 public typealias Generator
SwiftyJSON.swift:280
    public func generate() -> JSON.Generator {
SwiftyJSON.swift:281
        return JSON.Generator(self)
= JSONGenerator 0201 0202 public typealias Index
SwiftyJSON.swift:204
    public var startIndex: JSON.Index {
SwiftyJSON.swift:215
    public var endIndex: JSON.Index {
= JSONIndex 0203 0204 public var startIndex: JSON.Index { 0205 switch self.type { 0206 case .Array: 0207 return JSONIndex(arrayIndex: self.rawArray.startIndex) 0208 case .Dictionary: 0209 return JSONIndex(dictionaryIndex: self.rawDictionary.startIndex) 0210 default: 0211 return JSONIndex() 0212 } 0213 } 0214 0215 public var endIndex: JSON.Index { 0216 switch self.type { 0217 case .Array: 0218 return JSONIndex(arrayIndex: self.rawArray.endIndex) 0219 case .Dictionary: 0220 return JSONIndex(dictionaryIndex: self.rawDictionary.endIndex) 0221 default: 0222 return JSONIndex() 0223 } 0224 } 0225 0226 public subscript (position: JSON.Index) -> JSON.Generator.Element { 0227 switch self.type { 0228 case .Array: 0229 return (String(position.arrayIndex), JSON(self.rawArray[position.arrayIndex!])) 0230 case .Dictionary: 0231 let (key, value) = self.rawDictionary[position.dictionaryIndex!] 0232 return (key, JSON(value)) 0233 default: 0234 return ("", JSON.null) 0235 } 0236 } 0237 0238 /// If `type` is `.Array` or `.Dictionary`, return `array.empty` or `dictonary.empty` otherwise return `true`. 0239 public var isEmpty: Bool { 0240 get { 0241 switch self.type { 0242 case .Array: 0243 return self.rawArray.isEmpty 0244 case .Dictionary: 0245 return self.rawDictionary.isEmpty 0246 default: 0247 return true 0248 } 0249 } 0250 } 0251 0252 /// If `type` is `.Array` or `.Dictionary`, return `array.count` or `dictonary.count` otherwise return `0`. 0253 public var count: Int { 0254 switch self.type { 0255 case .Array: 0256 return self.rawArray.count 0257 case .Dictionary: 0258 return self.rawDictionary.count 0259 default: 0260 return 0 0261 } 0262 } 0263 0264 public func underestimateCount() -> Int { 0265 switch self.type { 0266 case .Array: 0267 return self.rawArray.underestimateCount() 0268 case .Dictionary: 0269 return self.rawDictionary.underestimateCount() 0270 default: 0271 return 0 0272 } 0273 } 0274 0275 /** 0276 If `type` is `.Array` or `.Dictionary`, return a generator over the elements like `Array` or `Dictionary`, otherwise return a generator over empty. 0277 0278 - returns: Return a *generator* over the elements of JSON. 0279 */ 0280 public func generate() -> JSON.Generator { 0281 return JSON.Generator(self) 0282 } 0283 } 0284 0285 public struct JSONIndex
SwiftyJSON.swift:202
    public typealias Index = JSONIndex
SwiftyJSON.swift:207
            return JSONIndex(arrayIndex: self.rawArray.startIndex)
SwiftyJSON.swift:209
            return JSONIndex(dictionaryIndex: self.rawDictionary.startIndex)
SwiftyJSON.swift:211
            return JSONIndex()
SwiftyJSON.swift:218
            return JSONIndex(arrayIndex: self.rawArray.endIndex)
SwiftyJSON.swift:220
            return JSONIndex(dictionaryIndex: self.rawDictionary.endIndex)
SwiftyJSON.swift:222
            return JSONIndex()
SwiftyJSON.swift:310
    public func successor() -> JSONIndex {
SwiftyJSON.swift:313
            return JSONIndex(arrayIndex: self.arrayIndex!.successor())
SwiftyJSON.swift:315
            return JSONIndex(dictionaryIndex: self.dictionaryIndex!.successor())
SwiftyJSON.swift:317
            return JSONIndex()
SwiftyJSON.swift:322
public func ==(lhs: JSONIndex, rhs: JSONIndex) -> Bool {
SwiftyJSON.swift:322
public func ==(lhs: JSONIndex, rhs: JSONIndex) -> Bool {
SwiftyJSON.swift:333
public func <(lhs: JSONIndex, rhs: JSONIndex) -> Bool {
SwiftyJSON.swift:333
public func <(lhs: JSONIndex, rhs: JSONIndex) -> Bool {
SwiftyJSON.swift:344
public func <=(lhs: JSONIndex, rhs: JSONIndex) -> Bool {
SwiftyJSON.swift:344
public func <=(lhs: JSONIndex, rhs: JSONIndex) -> Bool {
SwiftyJSON.swift:355
public func >=(lhs: JSONIndex, rhs: JSONIndex) -> Bool {
SwiftyJSON.swift:355
public func >=(lhs: JSONIndex, rhs: JSONIndex) -> Bool {
SwiftyJSON.swift:366
public func >(lhs: JSONIndex, rhs: JSONIndex) -> Bool {
SwiftyJSON.swift:366
public func >(lhs: JSONIndex, rhs: JSONIndex) -> Bool {
: ForwardIndexType, _Incrementable, Equatable, Comparable { 0286 0287 let arrayIndex
SwiftyJSON.swift:229
            return (String(position.arrayIndex), JSON(self.rawArray[position.arrayIndex!]))
SwiftyJSON.swift:229
            return (String(position.arrayIndex), JSON(self.rawArray[position.arrayIndex!]))
SwiftyJSON.swift:293
        self.arrayIndex = nil
SwiftyJSON.swift:299
        self.arrayIndex = arrayIndex
SwiftyJSON.swift:305
        self.arrayIndex = nil
SwiftyJSON.swift:313
            return JSONIndex(arrayIndex: self.arrayIndex!.successor())
SwiftyJSON.swift:325
        return lhs.arrayIndex == rhs.arrayIndex
SwiftyJSON.swift:325
        return lhs.arrayIndex == rhs.arrayIndex
SwiftyJSON.swift:336
        return lhs.arrayIndex < rhs.arrayIndex
SwiftyJSON.swift:336
        return lhs.arrayIndex < rhs.arrayIndex
SwiftyJSON.swift:347
        return lhs.arrayIndex <= rhs.arrayIndex
SwiftyJSON.swift:347
        return lhs.arrayIndex <= rhs.arrayIndex
SwiftyJSON.swift:358
        return lhs.arrayIndex >= rhs.arrayIndex
SwiftyJSON.swift:358
        return lhs.arrayIndex >= rhs.arrayIndex
SwiftyJSON.swift:369
        return lhs.arrayIndex > rhs.arrayIndex
SwiftyJSON.swift:369
        return lhs.arrayIndex > rhs.arrayIndex
: Int? 0288 let dictionaryIndex
SwiftyJSON.swift:231
            let (key, value) = self.rawDictionary[position.dictionaryIndex!]
SwiftyJSON.swift:294
        self.dictionaryIndex = nil
SwiftyJSON.swift:300
        self.dictionaryIndex = nil
SwiftyJSON.swift:306
        self.dictionaryIndex = dictionaryIndex
SwiftyJSON.swift:315
            return JSONIndex(dictionaryIndex: self.dictionaryIndex!.successor())
SwiftyJSON.swift:327
        return lhs.dictionaryIndex == rhs.dictionaryIndex
SwiftyJSON.swift:327
        return lhs.dictionaryIndex == rhs.dictionaryIndex
SwiftyJSON.swift:338
        return lhs.dictionaryIndex < rhs.dictionaryIndex
SwiftyJSON.swift:338
        return lhs.dictionaryIndex < rhs.dictionaryIndex
SwiftyJSON.swift:349
        return lhs.dictionaryIndex <= rhs.dictionaryIndex
SwiftyJSON.swift:349
        return lhs.dictionaryIndex <= rhs.dictionaryIndex
SwiftyJSON.swift:360
        return lhs.dictionaryIndex >= rhs.dictionaryIndex
SwiftyJSON.swift:360
        return lhs.dictionaryIndex >= rhs.dictionaryIndex
SwiftyJSON.swift:371
        return lhs.dictionaryIndex > rhs.dictionaryIndex
SwiftyJSON.swift:371
        return lhs.dictionaryIndex > rhs.dictionaryIndex
: DictionaryIndex<String, AnyObject>? 0289 0290 let type
SwiftyJSON.swift:295
        self.type = .Unknown
SwiftyJSON.swift:301
        self.type = .Array
SwiftyJSON.swift:307
        self.type = .Dictionary
SwiftyJSON.swift:311
        switch self.type {
SwiftyJSON.swift:323
    switch (lhs.type, rhs.type) {
SwiftyJSON.swift:323
    switch (lhs.type, rhs.type) {
SwiftyJSON.swift:334
    switch (lhs.type, rhs.type) {
SwiftyJSON.swift:334
    switch (lhs.type, rhs.type) {
SwiftyJSON.swift:345
    switch (lhs.type, rhs.type) {
SwiftyJSON.swift:345
    switch (lhs.type, rhs.type) {
SwiftyJSON.swift:356
    switch (lhs.type, rhs.type) {
SwiftyJSON.swift:356
    switch (lhs.type, rhs.type) {
SwiftyJSON.swift:367
    switch (lhs.type, rhs.type) {
SwiftyJSON.swift:367
    switch (lhs.type, rhs.type) {
: Type 0291 0292 init
SwiftyJSON.swift:211
            return JSONIndex()
SwiftyJSON.swift:222
            return JSONIndex()
SwiftyJSON.swift:317
            return JSONIndex()
(){ 0293 self.arrayIndex = nil 0294 self.dictionaryIndex = nil 0295 self.type = .Unknown 0296 } 0297 0298 init
SwiftyJSON.swift:207
            return JSONIndex(arrayIndex: self.rawArray.startIndex)
SwiftyJSON.swift:218
            return JSONIndex(arrayIndex: self.rawArray.endIndex)
SwiftyJSON.swift:313
            return JSONIndex(arrayIndex: self.arrayIndex!.successor())
(arrayIndex: Int) { 0299 self.arrayIndex = arrayIndex 0300 self.dictionaryIndex = nil 0301 self.type = .Array 0302 } 0303 0304 init
SwiftyJSON.swift:209
            return JSONIndex(dictionaryIndex: self.rawDictionary.startIndex)
SwiftyJSON.swift:220
            return JSONIndex(dictionaryIndex: self.rawDictionary.endIndex)
SwiftyJSON.swift:315
            return JSONIndex(dictionaryIndex: self.dictionaryIndex!.successor())
(dictionaryIndex: DictionaryIndex<String, AnyObject>) { 0305 self.arrayIndex = nil 0306 self.dictionaryIndex = dictionaryIndex 0307 self.type = .Dictionary 0308 } 0309 0310 public func successor() -> JSONIndex { 0311 switch self.type { 0312 case .Array: 0313 return JSONIndex(arrayIndex: self.arrayIndex!.successor()) 0314 case .Dictionary: 0315 return JSONIndex(dictionaryIndex: self.dictionaryIndex!.successor()) 0316 default: 0317 return JSONIndex() 0318 } 0319 } 0320 } 0321 0322 public func ==(lhs: JSONIndex, rhs: JSONIndex) -> Bool { 0323 switch (lhs.type, rhs.type) { 0324 case (.Array, .Array): 0325 return lhs.arrayIndex == rhs.arrayIndex 0326 case (.Dictionary, .Dictionary): 0327 return lhs.dictionaryIndex == rhs.dictionaryIndex 0328 default: 0329 return false 0330 } 0331 } 0332 0333 public func <(lhs: JSONIndex, rhs: JSONIndex) -> Bool { 0334 switch (lhs.type, rhs.type) { 0335 case (.Array, .Array): 0336 return lhs.arrayIndex < rhs.arrayIndex 0337 case (.Dictionary, .Dictionary): 0338 return lhs.dictionaryIndex < rhs.dictionaryIndex 0339 default: 0340 return false 0341 } 0342 } 0343 0344 public func <=(lhs: JSONIndex, rhs: JSONIndex) -> Bool { 0345 switch (lhs.type, rhs.type) { 0346 case (.Array, .Array): 0347 return lhs.arrayIndex <= rhs.arrayIndex 0348 case (.Dictionary, .Dictionary): 0349 return lhs.dictionaryIndex <= rhs.dictionaryIndex 0350 default: 0351 return false 0352 } 0353 } 0354 0355 public func >=(lhs: JSONIndex, rhs: JSONIndex) -> Bool { 0356 switch (lhs.type, rhs.type) { 0357 case (.Array, .Array): 0358 return lhs.arrayIndex >= rhs.arrayIndex 0359 case (.Dictionary, .Dictionary): 0360 return lhs.dictionaryIndex >= rhs.dictionaryIndex 0361 default: 0362 return false 0363 } 0364 } 0365 0366 public func >(lhs: JSONIndex, rhs: JSONIndex) -> Bool { 0367 switch (lhs.type, rhs.type) { 0368 case (.Array, .Array): 0369 return lhs.arrayIndex > rhs.arrayIndex 0370 case (.Dictionary, .Dictionary): 0371 return lhs.dictionaryIndex > rhs.dictionaryIndex 0372 default: 0373 return false 0374 } 0375 } 0376 0377 public struct JSONGenerator
SwiftyJSON.swift:200
    public typealias Generator = JSONGenerator
SwiftyJSON.swift:395
    public mutating func next() -> JSONGenerator.Element? {
: GeneratorType { 0378 0379 public typealias Element
SwiftyJSON.swift:395
    public mutating func next() -> JSONGenerator.Element? {
= (String, JSON) 0380 0381 private let type
SwiftyJSON.swift:387
        self.type = json.type
SwiftyJSON.swift:388
        if type == .Array {
SwiftyJSON.swift:396
        switch self.type {
: Type 0382 private var dictionayGenerate
SwiftyJSON.swift:391
            self.dictionayGenerate = json.rawDictionary.generate()
SwiftyJSON.swift:404
            if let (k, v): (String, AnyObject) = self.dictionayGenerate?.next() {
: DictionaryGenerator<String, AnyObject>? 0383 private var arrayGenerate
SwiftyJSON.swift:389
            self.arrayGenerate = json.rawArray.generate()
SwiftyJSON.swift:398
            if let o = self.arrayGenerate?.next() {
: IndexingGenerator<[AnyObject]>? 0384 private var arrayIndex
SwiftyJSON.swift:399
                return (String(self.arrayIndex++), JSON(o))
: Int = 0 0385 0386 init
SwiftyJSON.swift:281
        return JSON.Generator(self)
(_ json: JSON) { 0387 self.type = json.type 0388 if type == .Array { 0389 self.arrayGenerate = json.rawArray.generate() 0390 }else { 0391 self.dictionayGenerate = json.rawDictionary.generate() 0392 } 0393 } 0394 0395 public mutating func next() -> JSONGenerator.Element? { 0396 switch self.type { 0397 case .Array: 0398 if let o = self.arrayGenerate?.next() { 0399 return (String(self.arrayIndex++), JSON(o)) 0400 } else { 0401 return nil 0402 } 0403 case .Dictionary: 0404 if let (k, v): (String, AnyObject) = self.dictionayGenerate?.next() { 0405 return (k, JSON(v)) 0406 } else { 0407 return nil 0408 } 0409 default: 0410 return nil 0411 } 0412 } 0413 } 0414 0415 // MARK: - Subscript 0416 0417 /** 0418 * To mark both String and Int can be used in subscript. 0419 */ 0420 public enum JSONKey
SwiftyJSON.swift:426
    var jsonKey:JSONKey { get }
SwiftyJSON.swift:431
        return JSONKey.Index(self)
SwiftyJSON.swift:430
    public var jsonKey:JSONKey {
SwiftyJSON.swift:437
        return JSONKey.Key(self)
SwiftyJSON.swift:436
    public var jsonKey:JSONKey {
{ 0421 case Index
SwiftyJSON.swift:431
        return JSONKey.Index(self)
SwiftyJSON.swift:493
            case .Index(let index): return self[index: index]
SwiftyJSON.swift:499
            case .Index(let index): self[index: index] = newValue
(Int) 0422 case Key
SwiftyJSON.swift:437
        return JSONKey.Key(self)
SwiftyJSON.swift:494
            case .Key(let key): return self[key: key]
SwiftyJSON.swift:500
            case .Key(let key): self[key: key] = newValue
(String) 0423 } 0424 0425 public protocol JSONSubscriptType
SwiftyJSON.swift:429
extension Int: JSONSubscriptType {
SwiftyJSON.swift:435
extension String: JSONSubscriptType {
{ 0426 var jsonKey
SwiftyJSON.swift:492
            switch sub.jsonKey {
SwiftyJSON.swift:498
            switch sub.jsonKey {
:JSONKey { get } 0427 } 0428 0429 extension Int: JSONSubscriptType { 0430 public var jsonKey:JSONKey { 0431 return JSONKey.Index(self) 0432 } 0433 } 0434 0435 extension String: JSONSubscriptType { 0436 public var jsonKey:JSONKey { 0437 return JSONKey.Key(self) 0438 } 0439 } 0440 0441 extension JSON { 0442 0443 /// If `type` is `.Array`, return json which's object is `array[index]`, otherwise return null json with error. 0444 private subscript
SwiftyJSON.swift:493
            case .Index(let index): return self[index: index]
SwiftyJSON.swift:499
            case .Index(let index): self[index: index] = newValue
(index index: Int) -> JSON { 0445 get { 0446 if self.type != .Array { 0447 var r = JSON.null 0448 r._error = self._error ?? NSError(domain: ErrorDomain, code: ErrorWrongType, userInfo: [NSLocalizedDescriptionKey: "Array[\(index)] failure, It is not an array"]) 0449 return r 0450 } else if index >= 0 && index < self.rawArray.count { 0451 return JSON(self.rawArray[index]) 0452 } else { 0453 var r = JSON.null 0454 r._error = NSError(domain: ErrorDomain, code:ErrorIndexOutOfBounds , userInfo: [NSLocalizedDescriptionKey: "Array[\(index)] is out of bounds"]) 0455 return r 0456 } 0457 } 0458 set { 0459 if self.type == .Array { 0460 if self.rawArray.count > index && newValue.error == nil { 0461 self.rawArray[index] = newValue.object 0462 } 0463 } 0464 } 0465 } 0466 0467 /// If `type` is `.Dictionary`, return json which's object is `dictionary[key]` , otherwise return null json with error. 0468 private subscript
SwiftyJSON.swift:494
            case .Key(let key): return self[key: key]
SwiftyJSON.swift:500
            case .Key(let key): self[key: key] = newValue
(key key: String) -> JSON { 0469 get { 0470 var r = JSON.null 0471 if self.type == .Dictionary { 0472 if let o = self.rawDictionary[key] { 0473 r = JSON(o) 0474 } else { 0475 r._error = NSError(domain: ErrorDomain, code: ErrorNotExist, userInfo: [NSLocalizedDescriptionKey: "Dictionary[\"\(key)\"] does not exist"]) 0476 } 0477 } else { 0478 r._error = self._error ?? NSError(domain: ErrorDomain, code: ErrorWrongType, userInfo: [NSLocalizedDescriptionKey: "Dictionary[\"\(key)\"] failure, It is not an dictionary"]) 0479 } 0480 return r 0481 } 0482 set { 0483 if self.type == .Dictionary && newValue.error == nil { 0484 self.rawDictionary[key] = newValue.object 0485 } 0486 } 0487 } 0488 0489 /// If `sub` is `Int`, return `subscript(index:)`; If `sub` is `String`, return `subscript(key:)`. 0490 private subscript
SwiftyJSON.swift:520
            return path.reduce(self) { $0[sub: $1] }
SwiftyJSON.swift:527
                self[sub:path[0]].object = newValue.object
SwiftyJSON.swift:530
                var nextJSON = self[sub: path[0]]
SwiftyJSON.swift:532
                self[sub: path[0]] = nextJSON
(sub sub: JSONSubscriptType) -> JSON { 0491 get { 0492 switch sub.jsonKey { 0493 case .Index(let index): return self[index: index] 0494 case .Key(let key): return self[key: key] 0495 } 0496 } 0497 set { 0498 switch sub.jsonKey { 0499 case .Index(let index): self[index: index] = newValue 0500 case .Key(let key): self[key: key] = newValue 0501 } 0502 } 0503 } 0504 0505 /** 0506 Find a json in the complex data structuresby using the Int/String's array. 0507 0508 - parameter path: The target json's path. Example: 0509 0510 let json = JSON[data] 0511 let path = [9,"list","person","name"] 0512 let name = json[path] 0513 0514 The same as: let name = json[9]["list"]["person"]["name"] 0515 0516 - returns: Return a json found by the path or a null json with error 0517 */ 0518 public subscript
SwiftyJSON.swift:531
                nextJSON[aPath] = newValue
SwiftyJSON.swift:550
            return self[path]
SwiftyJSON.swift:553
            self[path] = newValue
(path: [JSONSubscriptType]) -> JSON { 0519 get { 0520 return path.reduce(self) { $0[sub: $1] } 0521 } 0522 set { 0523 switch path.count { 0524 case 0: 0525 return 0526 case 1: 0527 self[sub:path[0]].object = newValue.object 0528 default: 0529 var aPath = path; aPath.removeAtIndex(0) 0530 var nextJSON = self[sub: path[0]] 0531 nextJSON[aPath] = newValue 0532 self[sub: path[0]] = nextJSON 0533 } 0534 } 0535 } 0536 0537 /** 0538 Find a json in the complex data structuresby using the Int/String's array. 0539 0540 - parameter path: The target json's path. Example: 0541 0542 let name = json[9,"list","person","name"] 0543 0544 The same as: let name = json[9]["list"]["person"]["name"] 0545 0546 - returns: Return a json found by the path or a null json with error 0547 */ 0548 public subscript(path: JSONSubscriptType...) -> JSON { 0549 get { 0550 return self[path] 0551 } 0552 set { 0553 self[path] = newValue 0554 } 0555 } 0556 } 0557 0558 // MARK: - LiteralConvertible 0559 0560 extension JSON: Swift.StringLiteralConvertible { 0561 0562 public init(stringLiteral value: StringLiteralType) { 0563 self.init(value) 0564 } 0565 0566 public init(extendedGraphemeClusterLiteral value: StringLiteralType) { 0567 self.init(value) 0568 } 0569 0570 public init(unicodeScalarLiteral value: StringLiteralType) { 0571 self.init(value) 0572 } 0573 } 0574 0575 extension JSON: Swift.IntegerLiteralConvertible { 0576 0577 public init(integerLiteral value: IntegerLiteralType) { 0578 self.init(value) 0579 } 0580 } 0581 0582 extension JSON: Swift.BooleanLiteralConvertible { 0583 0584 public init(booleanLiteral value: BooleanLiteralType) { 0585 self.init(value) 0586 } 0587 } 0588 0589 extension JSON: Swift.FloatLiteralConvertible { 0590 0591 public init(floatLiteral value: FloatLiteralType) { 0592 self.init(value) 0593 } 0594 } 0595 0596 extension JSON: Swift.DictionaryLiteralConvertible { 0597 0598 public init(dictionaryLiteral elements: (String, AnyObject)...) { 0599 self.init(elements.reduce([String : AnyObject]()){(dictionary: [String : AnyObject], element:(String, AnyObject)) -> [String : AnyObject] in 0600 var d = dictionary 0601 d[element.0] = element.1 0602 return d 0603 }) 0604 } 0605 } 0606 0607 extension JSON: Swift.ArrayLiteralConvertible { 0608 0609 public init(arrayLiteral elements: AnyObject...) { 0610 self.init(elements) 0611 } 0612 } 0613 0614 extension JSON: Swift.NilLiteralConvertible { 0615 0616 public init(nilLiteral: ()) { 0617 self.init(NSNull()) 0618 } 0619 } 0620 0621 // MARK: - Raw 0622 0623 extension JSON: Swift.RawRepresentable { 0624 0625 public init?(rawValue: AnyObject) { 0626 if JSON(rawValue).type == .Unknown { 0627 return nil 0628 } else { 0629 self.init(rawValue) 0630 } 0631 } 0632 0633 public var rawValue: AnyObject { 0634 return self.object 0635 } 0636 0637 public func rawData
SwiftyJSON.swift:649
                let data = try self.rawData(options: opt)
(options opt: NSJSONWritingOptions = NSJSONWritingOptions(rawValue: 0)) throws -> NSData { 0638 guard NSJSONSerialization.isValidJSONObject(self.object) else { 0639 throw NSError(domain: ErrorDomain, code: ErrorInvalidJSON, userInfo: [NSLocalizedDescriptionKey: "JSON is invalid"]) 0640 } 0641 0642 return try NSJSONSerialization.dataWithJSONObject(self.object, options: opt) 0643 } 0644 0645 public func rawString
SwiftyJSON.swift:673
        if let string = self.rawString(options:.PrettyPrinted) {
(encoding: UInt = NSUTF8StringEncoding, options opt: NSJSONWritingOptions = .PrettyPrinted) -> String? { 0646 switch self.type { 0647 case .Array, .Dictionary: 0648 do { 0649 let data = try self.rawData(options: opt) 0650 return NSString(data: data, encoding: encoding) as? String 0651 } catch _ { 0652 return nil 0653 } 0654 case .String: 0655 return self.rawString 0656 case .Number: 0657 return self.rawNumber.stringValue 0658 case .Bool: 0659 return self.rawNumber.boolValue.description 0660 case .Null: 0661 return "null" 0662 default: 0663 return nil 0664 } 0665 } 0666 } 0667 0668 // MARK: - Printable, DebugPrintable 0669 0670 extension JSON: Swift.Printable, Swift.DebugPrintable { 0671 0672 public var description
SwiftyJSON.swift:681
        return description
: String { 0673 if let string = self.rawString(options:.PrettyPrinted) { 0674 return string 0675 } else { 0676 return "unknown" 0677 } 0678 } 0679 0680 public var debugDescription: String { 0681 return description 0682 } 0683 } 0684 0685 // MARK: - Array 0686 0687 extension JSON { 0688 0689 //Optional [JSON] 0690 public var array
SwiftyJSON.swift:703
            return self.array ?? []
: [JSON]? { 0691 get { 0692 if self.type == .Array { 0693 return self.rawArray.map{ JSON($0) } 0694 } else { 0695 return nil 0696 } 0697 } 0698 } 0699 0700 //Non-optional [JSON] 0701 public var arrayValue: [JSON] { 0702 get { 0703 return self.array ?? [] 0704 } 0705 } 0706 0707 //Optional [AnyObject] 0708 public var arrayObject: [AnyObject]? { 0709 get { 0710 switch self.type { 0711 case .Array: 0712 return self.rawArray 0713 default: 0714 return nil 0715 } 0716 } 0717 set { 0718 if let array = newValue { 0719 self.object = array 0720 } else { 0721 self.object = NSNull() 0722 } 0723 } 0724 } 0725 } 0726 0727 // MARK: - Dictionary 0728 0729 extension JSON { 0730 0731 //Optional [String : JSON] 0732 public var dictionary
SwiftyJSON.swift:746
        return self.dictionary ?? [:]
: [String : JSON]? { 0733 if self.type == .Dictionary { 0734 return self.rawDictionary.reduce([String : JSON]()) { (dictionary: [String : JSON], element: (String, AnyObject)) -> [String : JSON] in 0735 var d = dictionary 0736 d[element.0] = JSON(element.1) 0737 return d 0738 } 0739 } else { 0740 return nil 0741 } 0742 } 0743 0744 //Non-optional [String : JSON] 0745 public var dictionaryValue: [String : JSON] { 0746 return self.dictionary ?? [:] 0747 } 0748 0749 //Optional [String : AnyObject] 0750 public var dictionaryObject: [String : AnyObject]? { 0751 get { 0752 switch self.type { 0753 case .Dictionary: 0754 return self.rawDictionary 0755 default: 0756 return nil 0757 } 0758 } 0759 set { 0760 if let v = newValue { 0761 self.object = v 0762 } else { 0763 self.object = NSNull() 0764 } 0765 } 0766 } 0767 } 0768 0769 // MARK: - Bool 0770 0771 extension JSON: Swift.BooleanType { 0772 0773 //Optional bool 0774 public var bool: Bool? { 0775 get { 0776 switch self.type { 0777 case .Bool: 0778 return self.rawNumber.boolValue 0779 default: 0780 return nil 0781 } 0782 } 0783 set { 0784 if let newValue = newValue { 0785 self.object = NSNumber(bool: newValue) 0786 } else { 0787 self.object = NSNull() 0788 } 0789 } 0790 } 0791 0792 //Non-optional bool 0793 public var boolValue: Bool { 0794 get { 0795 switch self.type { 0796 case .Bool, .Number, .String: 0797 return self.object.boolValue 0798 default: 0799 return false 0800 } 0801 } 0802 set { 0803 self.object = NSNumber(bool: newValue) 0804 } 0805 } 0806 } 0807 0808 // MARK: - String 0809 0810 extension JSON { 0811 0812 //Optional string 0813 public var string: String? { 0814 get { 0815 switch self.type { 0816 case .String: 0817 return self.object as? String 0818 default: 0819 return nil 0820 } 0821 } 0822 set { 0823 if let newValue = newValue { 0824 self.object = NSString(string:newValue) 0825 } else { 0826 self.object = NSNull() 0827 } 0828 } 0829 } 0830 0831 //Non-optional string 0832 public var stringValue: String { 0833 get { 0834 switch self.type { 0835 case .String: 0836 return self.object as? String ?? "" 0837 case .Number: 0838 return self.object.stringValue 0839 case .Bool: 0840 return (self.object as? Bool).map { String($0) } ?? "" 0841 default: 0842 return "" 0843 } 0844 } 0845 set { 0846 self.object = NSString(string:newValue) 0847 } 0848 } 0849 } 0850 0851 // MARK: - Number 0852 extension JSON { 0853 0854 //Optional number 0855 public var number
SwiftyJSON.swift:944
            return self.number?.doubleValue
SwiftyJSON.swift:966
            return self.number?.floatValue
SwiftyJSON.swift:988
            return self.number?.longValue
SwiftyJSON.swift:1010
            return self.number?.unsignedLongValue
SwiftyJSON.swift:1032
            return self.number?.charValue
SwiftyJSON.swift:1054
            return self.number?.unsignedCharValue
SwiftyJSON.swift:1076
            return self.number?.shortValue
SwiftyJSON.swift:1098
            return self.number?.unsignedShortValue
SwiftyJSON.swift:1120
            return self.number?.intValue
SwiftyJSON.swift:1142
            return self.number?.unsignedIntValue
SwiftyJSON.swift:1164
            return self.number?.longLongValue
SwiftyJSON.swift:1186
            return self.number?.unsignedLongLongValue
: NSNumber? { 0856 get { 0857 switch self.type { 0858 case .Number, .Bool: 0859 return self.rawNumber 0860 default: 0861 return nil 0862 } 0863 } 0864 set { 0865 self.object = newValue ?? NSNull() 0866 } 0867 } 0868 0869 //Non-optional number 0870 public var numberValue
SwiftyJSON.swift:957
            return self.numberValue.doubleValue
SwiftyJSON.swift:979
            return self.numberValue.floatValue
SwiftyJSON.swift:1001
            return self.numberValue.integerValue
SwiftyJSON.swift:1023
            return self.numberValue.unsignedLongValue
SwiftyJSON.swift:1045
            return self.numberValue.charValue
SwiftyJSON.swift:1067
            return self.numberValue.unsignedCharValue
SwiftyJSON.swift:1089
            return self.numberValue.shortValue
SwiftyJSON.swift:1111
            return self.numberValue.unsignedShortValue
SwiftyJSON.swift:1133
            return self.numberValue.intValue
SwiftyJSON.swift:1155
            return self.numberValue.unsignedIntValue
SwiftyJSON.swift:1177
            return self.numberValue.longLongValue
SwiftyJSON.swift:1199
            return self.numberValue.unsignedLongLongValue
: NSNumber { 0871 get { 0872 switch self.type { 0873 case .String: 0874 let decimal = NSDecimalNumber(string: self.object as? String) 0875 if decimal == NSDecimalNumber.notANumber() { // indicates parse error 0876 return NSDecimalNumber.zero() 0877 } 0878 return decimal 0879 case .Number, .Bool: 0880 return self.object as? NSNumber ?? NSNumber(int: 0) 0881 default: 0882 return NSNumber(double: 0.0) 0883 } 0884 } 0885 set { 0886 self.object = newValue 0887 } 0888 } 0889 } 0890 0891 //MARK: - Null 0892 extension JSON { 0893 0894 public var null: NSNull? { 0895 get { 0896 switch self.type { 0897 case .Null: 0898 return self.rawNull 0899 default: 0900 return nil 0901 } 0902 } 0903 set { 0904 self.object = NSNull() 0905 } 0906 } 0907 public func isExists() -> Bool{ 0908 if let errorValue = error where errorValue.code == ErrorNotExist{ 0909 return false 0910 } 0911 return true 0912 } 0913 } 0914 0915 //MARK: - URL 0916 extension JSON { 0917 0918 //Optional URL 0919 public var URL: NSURL? { 0920 get { 0921 switch self.type { 0922 case .String: 0923 if let encodedString_ = self.rawString.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet()) { 0924 return NSURL(string: encodedString_) 0925 } else { 0926 return nil 0927 } 0928 default: 0929 return nil 0930 } 0931 } 0932 set { 0933 self.object = newValue?.absoluteString ?? NSNull() 0934 } 0935 } 0936 } 0937 0938 // MARK: - Int, Double, Float, Int8, Int16, Int32, Int64 0939 0940 extension JSON { 0941 0942 public var double: Double? { 0943 get { 0944 return self.number?.doubleValue 0945 } 0946 set { 0947 if let newValue = newValue { 0948 self.object = NSNumber(double: newValue) 0949 } else { 0950 self.object = NSNull() 0951 } 0952 } 0953 } 0954 0955 public var doubleValue: Double { 0956 get { 0957 return self.numberValue.doubleValue 0958 } 0959 set { 0960 self.object = NSNumber(double: newValue) 0961 } 0962 } 0963 0964 public var float: Float? { 0965 get { 0966 return self.number?.floatValue 0967 } 0968 set { 0969 if let newValue = newValue { 0970 self.object = NSNumber(float: newValue) 0971 } else { 0972 self.object = NSNull() 0973 } 0974 } 0975 } 0976 0977 public var floatValue: Float { 0978 get { 0979 return self.numberValue.floatValue 0980 } 0981 set { 0982 self.object = NSNumber(float: newValue) 0983 } 0984 } 0985 0986 public var int: Int? { 0987 get { 0988 return self.number?.longValue 0989 } 0990 set { 0991 if let newValue = newValue { 0992 self.object = NSNumber(integer: newValue) 0993 } else { 0994 self.object = NSNull() 0995 } 0996 } 0997 } 0998 0999 public var intValue: Int { 1000 get { 1001 return self.numberValue.integerValue 1002 } 1003 set { 1004 self.object = NSNumber(integer: newValue) 1005 } 1006 } 1007 1008 public var uInt: UInt? { 1009 get { 1010 return self.number?.unsignedLongValue 1011 } 1012 set { 1013 if let newValue = newValue { 1014 self.object = NSNumber(unsignedLong: newValue) 1015 } else { 1016 self.object = NSNull() 1017 } 1018 } 1019 } 1020 1021 public var uIntValue: UInt { 1022 get { 1023 return self.numberValue.unsignedLongValue 1024 } 1025 set { 1026 self.object = NSNumber(unsignedLong: newValue) 1027 } 1028 } 1029 1030 public var int8: Int8? { 1031 get { 1032 return self.number?.charValue 1033 } 1034 set { 1035 if let newValue = newValue { 1036 self.object = NSNumber(char: newValue) 1037 } else { 1038 self.object = NSNull() 1039 } 1040 } 1041 } 1042 1043 public var int8Value: Int8 { 1044 get { 1045 return self.numberValue.charValue 1046 } 1047 set { 1048 self.object = NSNumber(char: newValue) 1049 } 1050 } 1051 1052 public var uInt8: UInt8? { 1053 get { 1054 return self.number?.unsignedCharValue 1055 } 1056 set { 1057 if let newValue = newValue { 1058 self.object = NSNumber(unsignedChar: newValue) 1059 } else { 1060 self.object = NSNull() 1061 } 1062 } 1063 } 1064 1065 public var uInt8Value: UInt8 { 1066 get { 1067 return self.numberValue.unsignedCharValue 1068 } 1069 set { 1070 self.object = NSNumber(unsignedChar: newValue) 1071 } 1072 } 1073 1074 public var int16: Int16? { 1075 get { 1076 return self.number?.shortValue 1077 } 1078 set { 1079 if let newValue = newValue { 1080 self.object = NSNumber(short: newValue) 1081 } else { 1082 self.object = NSNull() 1083 } 1084 } 1085 } 1086 1087 public var int16Value: Int16 { 1088 get { 1089 return self.numberValue.shortValue 1090 } 1091 set { 1092 self.object = NSNumber(short: newValue) 1093 } 1094 } 1095 1096 public var uInt16: UInt16? { 1097 get { 1098 return self.number?.unsignedShortValue 1099 } 1100 set { 1101 if let newValue = newValue { 1102 self.object = NSNumber(unsignedShort: newValue) 1103 } else { 1104 self.object = NSNull() 1105 } 1106 } 1107 } 1108 1109 public var uInt16Value: UInt16 { 1110 get { 1111 return self.numberValue.unsignedShortValue 1112 } 1113 set { 1114 self.object = NSNumber(unsignedShort: newValue) 1115 } 1116 } 1117 1118 public var int32: Int32? { 1119 get { 1120 return self.number?.intValue 1121 } 1122 set { 1123 if let newValue = newValue { 1124 self.object = NSNumber(int: newValue) 1125 } else { 1126 self.object = NSNull() 1127 } 1128 } 1129 } 1130 1131 public var int32Value: Int32 { 1132 get { 1133 return self.numberValue.intValue 1134 } 1135 set { 1136 self.object = NSNumber(int: newValue) 1137 } 1138 } 1139 1140 public var uInt32: UInt32? { 1141 get { 1142 return self.number?.unsignedIntValue 1143 } 1144 set { 1145 if let newValue = newValue { 1146 self.object = NSNumber(unsignedInt: newValue) 1147 } else { 1148 self.object = NSNull() 1149 } 1150 } 1151 } 1152 1153 public var uInt32Value: UInt32 { 1154 get { 1155 return self.numberValue.unsignedIntValue 1156 } 1157 set { 1158 self.object = NSNumber(unsignedInt: newValue) 1159 } 1160 } 1161 1162 public var int64: Int64? { 1163 get { 1164 return self.number?.longLongValue 1165 } 1166 set { 1167 if let newValue = newValue { 1168 self.object = NSNumber(longLong: newValue) 1169 } else { 1170 self.object = NSNull() 1171 } 1172 } 1173 } 1174 1175 public var int64Value: Int64 { 1176 get { 1177 return self.numberValue.longLongValue 1178 } 1179 set { 1180 self.object = NSNumber(longLong: newValue) 1181 } 1182 } 1183 1184 public var uInt64: UInt64? { 1185 get { 1186 return self.number?.unsignedLongLongValue 1187 } 1188 set { 1189 if let newValue = newValue { 1190 self.object = NSNumber(unsignedLongLong: newValue) 1191 } else { 1192 self.object = NSNull() 1193 } 1194 } 1195 } 1196 1197 public var uInt64Value: UInt64 { 1198 get { 1199 return self.numberValue.unsignedLongLongValue 1200 } 1201 set { 1202 self.object = NSNumber(unsignedLongLong: newValue) 1203 } 1204 } 1205 } 1206 1207 //MARK: - Comparable 1208 extension JSON : Swift.Comparable {} 1209 1210 public func ==(lhs: JSON, rhs: JSON) -> Bool { 1211 1212 switch (lhs.type, rhs.type) { 1213 case (.Number, .Number): 1214 return lhs.rawNumber == rhs.rawNumber 1215 case (.String, .String): 1216 return lhs.rawString == rhs.rawString 1217 case (.Bool, .Bool): 1218 return lhs.rawNumber.boolValue == rhs.rawNumber.boolValue 1219 case (.Array, .Array): 1220 return lhs.rawArray as NSArray == rhs.rawArray as NSArray 1221 case (.Dictionary, .Dictionary): 1222 return lhs.rawDictionary as NSDictionary == rhs.rawDictionary as NSDictionary 1223 case (.Null, .Null): 1224 return true 1225 default: 1226 return false 1227 } 1228 } 1229 1230 public func <=(lhs: JSON, rhs: JSON) -> Bool { 1231 1232 switch (lhs.type, rhs.type) { 1233 case (.Number, .Number): 1234 return lhs.rawNumber <= rhs.rawNumber 1235 case (.String, .String): 1236 return lhs.rawString <= rhs.rawString 1237 case (.Bool, .Bool): 1238 return lhs.rawNumber.boolValue == rhs.rawNumber.boolValue 1239 case (.Array, .Array): 1240 return lhs.rawArray as NSArray == rhs.rawArray as NSArray 1241 case (.Dictionary, .Dictionary): 1242 return lhs.rawDictionary as NSDictionary == rhs.rawDictionary as NSDictionary 1243 case (.Null, .Null): 1244 return true 1245 default: 1246 return false 1247 } 1248 } 1249 1250 public func >=(lhs: JSON, rhs: JSON) -> Bool { 1251 1252 switch (lhs.type, rhs.type) { 1253 case (.Number, .Number): 1254 return lhs.rawNumber >= rhs.rawNumber 1255 case (.String, .String): 1256 return lhs.rawString >= rhs.rawString 1257 case (.Bool, .Bool): 1258 return lhs.rawNumber.boolValue == rhs.rawNumber.boolValue 1259 case (.Array, .Array): 1260 return lhs.rawArray as NSArray == rhs.rawArray as NSArray 1261 case (.Dictionary, .Dictionary): 1262 return lhs.rawDictionary as NSDictionary == rhs.rawDictionary as NSDictionary 1263 case (.Null, .Null): 1264 return true 1265 default: 1266 return false 1267 } 1268 } 1269 1270 public func >(lhs: JSON, rhs: JSON) -> Bool { 1271 1272 switch (lhs.type, rhs.type) { 1273 case (.Number, .Number): 1274 return lhs.rawNumber > rhs.rawNumber 1275 case (.String, .String): 1276 return lhs.rawString > rhs.rawString 1277 default: 1278 return false 1279 } 1280 } 1281 1282 public func <(lhs: JSON, rhs: JSON) -> Bool { 1283 1284 switch (lhs.type, rhs.type) { 1285 case (.Number, .Number): 1286 return lhs.rawNumber < rhs.rawNumber 1287 case (.String, .String): 1288 return lhs.rawString < rhs.rawString 1289 default: 1290 return false 1291 } 1292 } 1293 1294 private let trueNumber
SwiftyJSON.swift:1296
private let trueObjCType = String.fromCString(trueNumber.objCType)
SwiftyJSON.swift:1305
            if (self.compare(trueNumber) == NSComparisonResult.OrderedSame && objCType == trueObjCType)
= NSNumber(bool: true) 1295 private let falseNumber
SwiftyJSON.swift:1297
private let falseObjCType = String.fromCString(falseNumber.objCType)
SwiftyJSON.swift:1306
                || (self.compare(falseNumber) == NSComparisonResult.OrderedSame && objCType == falseObjCType){
= NSNumber(bool: false) 1296 private let trueObjCType
SwiftyJSON.swift:1305
            if (self.compare(trueNumber) == NSComparisonResult.OrderedSame && objCType == trueObjCType)
= String.fromCString(trueNumber.objCType) 1297 private let falseObjCType
SwiftyJSON.swift:1306
                || (self.compare(falseNumber) == NSComparisonResult.OrderedSame && objCType == falseObjCType){
= String.fromCString(falseNumber.objCType) 1298 1299 // MARK: - NSNumber: Comparable 1300 1301 extension NSNumber { 1302 var isBool
SwiftyJSON.swift:161
                if number.isBool {
SwiftyJSON.swift:1316
    switch (lhs.isBool, rhs.isBool) {
SwiftyJSON.swift:1316
    switch (lhs.isBool, rhs.isBool) {
SwiftyJSON.swift:1332
    switch (lhs.isBool, rhs.isBool) {
SwiftyJSON.swift:1332
    switch (lhs.isBool, rhs.isBool) {
SwiftyJSON.swift:1344
    switch (lhs.isBool, rhs.isBool) {
SwiftyJSON.swift:1344
    switch (lhs.isBool, rhs.isBool) {
SwiftyJSON.swift:1356
    switch (lhs.isBool, rhs.isBool) {
SwiftyJSON.swift:1356
    switch (lhs.isBool, rhs.isBool) {
SwiftyJSON.swift:1368
    switch (lhs.isBool, rhs.isBool) {
SwiftyJSON.swift:1368
    switch (lhs.isBool, rhs.isBool) {
:Bool { 1303 get { 1304 let objCType = String.fromCString(self.objCType) 1305 if (self.compare(trueNumber) == NSComparisonResult.OrderedSame && objCType == trueObjCType) 1306 || (self.compare(falseNumber) == NSComparisonResult.OrderedSame && objCType == falseObjCType){ 1307 return true 1308 } else { 1309 return false 1310 } 1311 } 1312 } 1313 } 1314 1315 func ==(lhs: NSNumber, rhs: NSNumber) -> Bool { 1316 switch (lhs.isBool, rhs.isBool) { 1317 case (false, true): 1318 return false 1319 case (true, false): 1320 return false 1321 default: 1322 return lhs.compare(rhs) == NSComparisonResult.OrderedSame 1323 } 1324 } 1325 1326 func !=(lhs: NSNumber, rhs: NSNumber) -> Bool { 1327 return !(lhs == rhs) 1328 } 1329 1330 func <(lhs: NSNumber, rhs: NSNumber) -> Bool { 1331 1332 switch (lhs.isBool, rhs.isBool) { 1333 case (false, true): 1334 return false 1335 case (true, false): 1336 return false 1337 default: 1338 return lhs.compare(rhs) == NSComparisonResult.OrderedAscending 1339 } 1340 } 1341 1342 func >(lhs: NSNumber, rhs: NSNumber) -> Bool { 1343 1344 switch (lhs.isBool, rhs.isBool) { 1345 case (false, true): 1346 return false 1347 case (true, false): 1348 return false 1349 default: 1350 return lhs.compare(rhs) == NSComparisonResult.OrderedDescending 1351 } 1352 } 1353 1354 func <=(lhs: NSNumber, rhs: NSNumber) -> Bool { 1355 1356 switch (lhs.isBool, rhs.isBool) { 1357 case (false, true): 1358 return false 1359 case (true, false): 1360 return false 1361 default: 1362 return lhs.compare(rhs) != NSComparisonResult.OrderedDescending 1363 } 1364 } 1365 1366 func >=(lhs: NSNumber, rhs: NSNumber) -> Bool { 1367 1368 switch (lhs.isBool, rhs.isBool) { 1369 case (false, true): 1370 return false 1371 case (true, false): 1372 return false 1373 default: 1374 return lhs.compare(rhs) != NSComparisonResult.OrderedAscending 1375 } 1376 } 1377