0001 import Foundation 0002 0003 // 0004 // Json.swift 0005 // JsonSerializer 0006 // 0007 // Created by Fuji Goro on 2014/09/15. 0008 // Copyright (c) 2014 Fuji Goro. All rights reserved. 0009 // 0010 0011 public enum Json: CustomStringConvertible, CustomDebugStringConvertible, Equatable { 0012 0013 case NullValue
JSONSerializer.swift:17 case ArrayValue([Json])JSONSerializer.swift:18 case ObjectValue([String:Json])JSONSerializer.swift:34 public init(_ value: [Json]) {JSONSerializer.swift:38 public init(_ value: [String : Json]) {JSONSerializer.swift:44 public static func from(value: Bool) -> Json {JSONSerializer.swift:48 public static func from(value: Double) -> Json {JSONSerializer.swift:52 public static func from(value: String) -> Json {JSONSerializer.swift:56 public static func from(value: [Json]) -> Json {JSONSerializer.swift:56 public static func from(value: [Json]) -> Json {JSONSerializer.swift:60 public static func from(value: [String : Json]) -> Json {JSONSerializer.swift:60 public static func from(value: [String : Json]) -> Json {JSONSerializer.swift:67 extension Json {JSONSerializer.swift:68 public static func deserialize(source: String) throws -> Json {JSONSerializer.swift:72 public static func deserialize(source: [UInt8]) throws -> Json {JSONSerializer.swift:76 public static func deserialize<ByteSequence: CollectionType where ByteSequence.Generator.Element == UInt8>(sequence: ByteSequence) throws -> Json {JSONSerializer.swift:81 extension Json {JSONSerializer.swift:103 extension Json {JSONSerializer.swift:157 public var arrayValue: [Json]? {JSONSerializer.swift:162 public var objectValue: [String : Json]? {JSONSerializer.swift:168 extension Json {JSONSerializer.swift:189 extension Json {JSONSerializer.swift:199 extension Json {JSONSerializer.swift:206 public func ==(lhs: Json, rhs: Json) -> Bool {JSONSerializer.swift:206 public func ==(lhs: Json, rhs: Json) -> Bool {JSONSerializer.swift:230 extension Json: NilLiteralConvertible {JSONSerializer.swift:236 extension Json: BooleanLiteralConvertible {JSONSerializer.swift:242 extension Json: IntegerLiteralConvertible {JSONSerializer.swift:248 extension Json: FloatLiteralConvertible {JSONSerializer.swift:254 extension Json: StringLiteralConvertible {JSONSerializer.swift:271 extension Json: ArrayLiteralConvertible {JSONSerializer.swift:272 public init(arrayLiteral elements: Json...) {JSONSerializer.swift:277 extension Json: DictionaryLiteralConvertible {JSONSerializer.swift:278 public init(dictionaryLiteral elements: (String, Json)...) {JSONSerializer.swift:279 var object = [String : Json](minimumCapacity: elements.count)JSONSerializer.swift:352 internal func deserialize() throws -> Json {JSONSerializer.swift:363 private func deserializeNextValue() throws -> Json {JSONSerializer.swift:371 return try parseSymbol("null", Json.NullValue)JSONSerializer.swift:373 return try parseSymbol("true", Json.BooleanValue(true))JSONSerializer.swift:375 return try parseSymbol("false", Json.BooleanValue(false))JSONSerializer.swift:389 private func parseSymbol(target: StaticString, @autoclosure _ iftrue: () -> Json) throws -> Json {JSONSerializer.swift:389 private func parseSymbol(target: StaticString, @autoclosure _ iftrue: () -> Json) throws -> Json {JSONSerializer.swift:397 private func parseString() throws -> Json {JSONSerializer.swift:465 private func parseNumber() throws -> Json {JSONSerializer.swift:527 private func parseObject() throws -> Json {JSONSerializer.swift:534 private func getObject() throws -> Json {JSONSerializer.swift:539 var object = [String:Json]()JSONSerializer.swift:569 private func parseArray() throws -> Json {JSONSerializer.swift:574 var a = Array<Json>()JSONSerializer.swift:701 func serialize(_: Json) -> StringJSONSerializer.swift:708 internal func serialize(json: Json) -> String {JSONSerializer.swift:733 func serializeArray(array: [Json]) -> String {JSONSerializer.swift:741 func serializeObject(object: [String : Json]) -> String {JSONSerializer.swift:762 override internal func serializeArray(array: [Json]) -> String {JSONSerializer.swift:780 override internal func serializeObject(object: [String : Json]) -> String {RequestData+Target.swift:39 public let json: Json?RequestData+Target.swift:45 self.json = try Json.deserialize(bytes)RequestData+Target.swift:104 extension Json: Node {Vapor+JSON.swift:12 public typealias JSON = JsonVapor+JSON.swift:16 extension Json: ResponseConvertible {Vapor+JSON.swift:32 return try? Json.deserialize(body)Vapor+JSON.swift:31 public var json: Json? {Vapor+JSON.swift:46 case UnableToConvert(json: Json, toType: String)Vapor+JSON.swift:63 static func newInstance(json: Json) throws -> SelfVapor+JSON.swift:72 func jsonRepresentation() throws -> JsonVapor+JSON.swift:77 extension Json {Vapor+JSON.swift:93 let mapped = try any.map(Json.init)Vapor+JSON.swift:98 let mapped = try any.map(Json.init)Vapor+JSON.swift:103 let mapped = try any.map(Json.init)Vapor+JSON.swift:108 var mapped: [String : Json] = [:]Vapor+JSON.swift:110 mapped[key] = try Json(val)Vapor+JSON.swift:116 var mapped: [String : Json] = [:]Vapor+JSON.swift:118 mapped[key] = try Json(val)Vapor+JSON.swift:124 var mapped: [String : Json] = [:]Vapor+JSON.swift:126 mapped[key] = try Json(val)Vapor+JSON.swift:132 extension Json : JsonConvertible {Vapor+JSON.swift:133 public static func newInstance(json: Json) -> Json {Vapor+JSON.swift:133 public static func newInstance(json: Json) -> Json {Vapor+JSON.swift:137 public func jsonRepresentation() -> Json {Vapor+JSON.swift:145 public func jsonRepresentation() throws -> Json {Vapor+JSON.swift:146 return Json(self)Vapor+JSON.swift:149 public static func newInstance(json: Json) throws -> String {Vapor+JSON.swift:160 public func jsonRepresentation() throws -> Json {Vapor+JSON.swift:161 return Json(self)Vapor+JSON.swift:164 public static func newInstance(json: Json) throws -> Bool {Vapor+JSON.swift:182 public func jsonRepresentation() throws -> Json {Vapor+JSON.swift:187 public static func newInstance(json: Json) throws -> Self {Vapor+JSON.swift:205 public func jsonRepresentation() throws -> Json {Vapor+JSON.swift:210 public static func newInstance(json: Json) throws -> Self {Vapor+JSON.swift:240 public func jsonRepresentation() throws -> Json {Vapor+JSON.swift:244 public static func newInstance(json: Json) throws -> Self {0014 case BooleanValue
JSONSerializer.swift:105 guard case .NullValue = self else { return false }JSONSerializer.swift:208 case .NullValue:JSONSerializer.swift:232 self = .NullValueJSONSerializer.swift:371 return try parseSymbol("null", Json.NullValue)JSONSerializer.swift:710 case .NullValue:RequestData+Target.swift:113 case .ObjectValue(_), .ArrayValue(_), .NullValue:RequestData+Target.swift:141 case .NullValue:RequestData+Target.swift:156 case .NullValue:(Bool) 0015 case NumberValue
JSONSerializer.swift:23 self = .BooleanValue(value)JSONSerializer.swift:45 return .BooleanValue(value)JSONSerializer.swift:110 if case let .BooleanValue(bool) = self {JSONSerializer.swift:210 case .BooleanValue(let lhsValue):JSONSerializer.swift:238 self = .BooleanValue(value)JSONSerializer.swift:373 return try parseSymbol("true", Json.BooleanValue(true))JSONSerializer.swift:375 return try parseSymbol("false", Json.BooleanValue(false))JSONSerializer.swift:712 case .BooleanValue(let b):RequestData+Target.swift:107 case .BooleanValue(let bool):RequestData+Target.swift:135 case .BooleanValue(let bool):RequestData+Target.swift:152 case .BooleanValue(let bool):(Double) 0016 case StringValue
JSONSerializer.swift:27 self = .NumberValue(value)JSONSerializer.swift:49 return .NumberValue(value)JSONSerializer.swift:129 guard case let .NumberValue(double) = self else {JSONSerializer.swift:137 guard case let .NumberValue(double) = self where double % 1 == 0 else {JSONSerializer.swift:216 case .NumberValue(let lhsValue):JSONSerializer.swift:244 self = .NumberValue(Double(value))JSONSerializer.swift:250 self = .NumberValue(Double(value))JSONSerializer.swift:524 return .NumberValue(sign * (Double(integer) + fraction) * pow(10, Double(exponent)))JSONSerializer.swift:714 case .NumberValue(let n):RequestData+Target.swift:109 case .NumberValue(let number):RequestData+Target.swift:137 case .NumberValue(let number):RequestData+Target.swift:154 case .NumberValue(let number):(String) 0017 case ArrayValue
JSONSerializer.swift:31 self = .StringValue(value)JSONSerializer.swift:53 return .StringValue(value)JSONSerializer.swift:150 guard case let .StringValue(string) = self else {JSONSerializer.swift:213 case .StringValue(let lhsValue):JSONSerializer.swift:259 self = .StringValue(value)JSONSerializer.swift:263 self = .StringValue(value)JSONSerializer.swift:267 self = .StringValue(value)JSONSerializer.swift:436 return .StringValue(string)JSONSerializer.swift:542 guard case let .StringValue(key) = try deserializeNextValue() else {JSONSerializer.swift:716 case .StringValue(let s):RequestData+Target.swift:111 case .StringValue(let string):RequestData+Target.swift:139 case .StringValue(let string):RequestData+Target.swift:150 case .StringValue(let string):([Json]) 0018 case ObjectValue
JSONSerializer.swift:35 self = .ArrayValue(value)JSONSerializer.swift:57 return .ArrayValue(value)JSONSerializer.swift:158 guard case let .ArrayValue(array) = self else { return nil }JSONSerializer.swift:219 case .ArrayValue(let lhsValue):JSONSerializer.swift:273 self = .ArrayValue(elements)JSONSerializer.swift:592 return .ArrayValue(a)JSONSerializer.swift:718 case .ArrayValue(let a):RequestData+Target.swift:113 case .ObjectValue(_), .ArrayValue(_), .NullValue:RequestData+Target.swift:143 case .ObjectValue(_), .ArrayValue(_):RequestData+Target.swift:158 case .ArrayValue(let array):RequestData+Target.swift:170 guard case let .ArrayValue(array) = self else { return nil }([String:Json]) 0019 0020 // MARK: Initialization 0021 0022 public init
JSONSerializer.swift:39 self = .ObjectValue(value)JSONSerializer.swift:61 return .ObjectValue(value)JSONSerializer.swift:163 guard case let .ObjectValue(object) = self else { return nil }JSONSerializer.swift:222 case .ObjectValue(let lhsValue):JSONSerializer.swift:283 self = .ObjectValue(object)JSONSerializer.swift:566 return .ObjectValue(object)JSONSerializer.swift:720 case .ObjectValue(let o):RequestData+Target.swift:113 case .ObjectValue(_), .ArrayValue(_), .NullValue:RequestData+Target.swift:143 case .ObjectValue(_), .ArrayValue(_):RequestData+Target.swift:164 case .ObjectValue(_):RequestData+Target.swift:175 guard case let .ObjectValue(object) = self else { return nil }(_ value: Bool) { 0023 self = .BooleanValue(value) 0024 } 0025 0026 public init(_ value: Double) { 0027 self = .NumberValue(value) 0028 } 0029 0030 public init
Vapor+JSON.swift:161 return Json(self)(_ value: String) { 0031 self = .StringValue(value) 0032 } 0033 0034 public init
Vapor+JSON.swift:146 return Json(self)(_ value: [Json]) { 0035 self = .ArrayValue(value) 0036 } 0037 0038 public init
Vapor+JSON.swift:94 self.init(mapped)Vapor+JSON.swift:99 self.init(mapped)Vapor+JSON.swift:104 self.init(mapped)(_ value: [String : Json]) { 0039 self = .ObjectValue(value) 0040 } 0041 0042 // MARK: From 0043 0044 public static func from(value: Bool) -> Json { 0045 return .BooleanValue(value) 0046 } 0047 0048 public static func from
Vapor+JSON.swift:112 self.init(mapped)Vapor+JSON.swift:120 self.init(mapped)Vapor+JSON.swift:128 self.init(mapped)(value: Double) -> Json { 0049 return .NumberValue(value) 0050 } 0051 0052 public static func from(value: String) -> Json { 0053 return .StringValue(value) 0054 } 0055 0056 public static func from(value: [Json]) -> Json { 0057 return .ArrayValue(value) 0058 } 0059 0060 public static func from
Vapor+JSON.swift:184 return .from(double)Vapor+JSON.swift:207 return .from(double)Vapor+JSON.swift:241 return .from(doubleValue)(value: [String : Json]) -> Json { 0061 return .ObjectValue(value) 0062 } 0063 } 0064 0065 // MARK: Serialization 0066 0067 extension Json { 0068 public static func deserialize(source: String) throws -> Json { 0069 return try JsonDeserializer(source.utf8).deserialize() 0070 } 0071 0072 public static func deserialize
JSONSerializer.swift:184 self = .from(mutableObject)(source: [UInt8]) throws -> Json { 0073 return try JsonDeserializer(source).deserialize() 0074 } 0075 0076 public static func deserialize<ByteSequence: CollectionType where ByteSequence.Generator.Element == UInt8>(sequence: ByteSequence) throws -> Json { 0077 return try JsonDeserializer(sequence).deserialize() 0078 } 0079 } 0080 0081 extension Json { 0082 public enum SerializationStyle
RequestData+Target.swift:45 self.json = try Json.deserialize(bytes)Vapor+JSON.swift:32 return try? Json.deserialize(body){ 0083 case Default
JSONSerializer.swift:96 public func serialize(style: SerializationStyle = .Default) -> String {0084 case PrettyPrint
JSONSerializer.swift:88 case .Default:JSONSerializer.swift:96 public func serialize(style: SerializationStyle = .Default) -> String {0085 0086 private var serializer
JSONSerializer.swift:90 case .PrettyPrint:: JsonSerializer.Type { 0087 switch self { 0088 case .Default: 0089 return DefaultJsonSerializer.self 0090 case .PrettyPrint: 0091 return PrettyJsonSerializer.self 0092 } 0093 } 0094 } 0095 0096 public func serialize
JSONSerializer.swift:97 return style.serializer.init().serialize(self)(style: SerializationStyle = .Default) -> String { 0097 return style.serializer.init().serialize(self) 0098 } 0099 } 0100 0101 // MARK: Convenience 0102 0103 extension Json { 0104 public var isNull
Vapor+JSON.swift:18 let js = serialize(): Bool { 0105 guard case .NullValue = self else { return false } 0106 return true 0107 } 0108 0109 public var boolValue
JSONSerializer.swift:209 return rhs.isNull: Bool? { 0110 if case let .BooleanValue(bool) = self { 0111 return bool 0112 } else if let integer = intValue where integer == 1 || integer == 0 { 0113 // When converting from foundation type `[String : AnyObject]`, something that I see as important, 0114 // it's not possible to distinguish between 'bool', 'double', and 'int'. 0115 // Because of this, if we have an integer that is 0 or 1, and a user is requesting a boolean val, 0116 // it's fairly likely this is their desired result. 0117 return integer == 1 0118 } else { 0119 return nil 0120 } 0121 } 0122 0123 public var floatValue: Float? { 0124 guard let double = doubleValue else { return nil } 0125 return Float(double) 0126 } 0127 0128 public var doubleValue
JSONSerializer.swift:211 guard let rhsValue = rhs.boolValue else { return false }Vapor+JSON.swift:165 guard let bool = json.boolValue else {: Double? { 0129 guard case let .NumberValue(double) = self else { 0130 return nil 0131 } 0132 0133 return double 0134 } 0135 0136 public var intValue
JSONSerializer.swift:124 guard let double = doubleValue else { return nil }JSONSerializer.swift:217 guard let rhsValue = rhs.doubleValue else { return false }Vapor+JSON.swift:245 guard let double = json.doubleValue else {: Int? { 0137 guard case let .NumberValue(double) = self where double % 1 == 0 else { 0138 return nil 0139 } 0140 0141 return Int(double) 0142 } 0143 0144 public var uintValue
JSONSerializer.swift:112 } else if let integer = intValue where integer == 1 || integer == 0 {JSONSerializer.swift:145 guard let intValue = intValue else { return nil }Vapor+JSON.swift:211 guard let int = json.intValue else {: UInt? { 0145 guard let intValue = intValue else { return nil } 0146 return UInt(intValue) 0147 } 0148 0149 public var stringValue
Vapor+JSON.swift:188 guard let int = json.uintValue else {: String? { 0150 guard case let .StringValue(string) = self else { 0151 return nil 0152 } 0153 0154 return string 0155 } 0156 0157 public var arrayValue
JSONSerializer.swift:214 guard let rhsValue = rhs.stringValue else { return false }Vapor+JSON.swift:150 guard let string = json.stringValue else {: [Json]? { 0158 guard case let .ArrayValue(array) = self else { return nil } 0159 return array 0160 } 0161 0162 public var objectValue
JSONSerializer.swift:171 guard let array = arrayValue where index < array.count else { return nil }JSONSerializer.swift:220 guard let rhsValue = rhs.arrayValue else { return false }: [String : Json]? { 0163 guard case let .ObjectValue(object) = self else { return nil } 0164 return object 0165 } 0166 } 0167 0168 extension Json { 0169 public subscript
JSONSerializer.swift:177 guard let dict = objectValue else { return nil }JSONSerializer.swift:181 guard let object = objectValue else { fatalError("Unable to set string subscript on non-object type!") }JSONSerializer.swift:223 guard let rhsValue = rhs.objectValue else { return false }(index: Int) -> Json? { 0170 assert(index >= 0) 0171 guard let array = arrayValue where index < array.count else { return nil } 0172 return array[index] 0173 } 0174 0175 public subscript
RequestData+Target.swift:65 return json?[idx](key: String) -> Json? { 0176 get { 0177 guard let dict = objectValue else { return nil } 0178 return dict[key] 0179 } 0180 set { 0181 guard let object = objectValue else { fatalError("Unable to set string subscript on non-object type!") } 0182 var mutableObject = object 0183 mutableObject[key] = newValue 0184 self = .from(mutableObject) 0185 } 0186 } 0187 } 0188 0189 extension Json { 0190 public var description: String { 0191 return serialize(DefaultJsonSerializer()) 0192 } 0193 0194 public var debugDescription: String { 0195 return serialize(PrettyJsonSerializer()) 0196 } 0197 } 0198 0199 extension Json { 0200 public func serialize
RequestData+Target.swift:61 return query[key] ?? json?[key](serializer: JsonSerializer) -> String { 0201 return serializer.serialize(self) 0202 } 0203 } 0204 0205 0206 public func ==(lhs: Json, rhs: Json) -> Bool { 0207 switch lhs { 0208 case .NullValue: 0209 return rhs.isNull 0210 case .BooleanValue(let lhsValue): 0211 guard let rhsValue = rhs.boolValue else { return false } 0212 return lhsValue == rhsValue 0213 case .StringValue(let lhsValue): 0214 guard let rhsValue = rhs.stringValue else { return false } 0215 return lhsValue == rhsValue 0216 case .NumberValue(let lhsValue): 0217 guard let rhsValue = rhs.doubleValue else { return false } 0218 return lhsValue == rhsValue 0219 case .ArrayValue(let lhsValue): 0220 guard let rhsValue = rhs.arrayValue else { return false } 0221 return lhsValue == rhsValue 0222 case .ObjectValue(let lhsValue): 0223 guard let rhsValue = rhs.objectValue else { return false } 0224 return lhsValue == rhsValue 0225 } 0226 } 0227 0228 // MARK: Literal Convertibles 0229 0230 extension Json: NilLiteralConvertible { 0231 public init(nilLiteral value: Void) { 0232 self = .NullValue 0233 } 0234 } 0235 0236 extension Json: BooleanLiteralConvertible { 0237 public init(booleanLiteral value: BooleanLiteralType) { 0238 self = .BooleanValue(value) 0239 } 0240 } 0241 0242 extension Json: IntegerLiteralConvertible { 0243 public init(integerLiteral value: IntegerLiteralType) { 0244 self = .NumberValue(Double(value)) 0245 } 0246 } 0247 0248 extension Json: FloatLiteralConvertible { 0249 public init(floatLiteral value: FloatLiteralType) { 0250 self = .NumberValue(Double(value)) 0251 } 0252 } 0253 0254 extension Json: StringLiteralConvertible { 0255 public typealias UnicodeScalarLiteralType
JSONSerializer.swift:191 return serialize(DefaultJsonSerializer())JSONSerializer.swift:195 return serialize(PrettyJsonSerializer())JSONSerializer.swift:736 .map { $0.serialize(self) }JSONSerializer.swift:746 let serializedVal = val.serialize(self)JSONSerializer.swift:773 let serialized = val.serialize(self)JSONSerializer.swift:792 let serializedValue = val.serialize(self)= String 0256 public typealias ExtendedGraphemeClusterLiteralType = String 0257 0258 public init(unicodeScalarLiteral value: UnicodeScalarLiteralType) { 0259 self = .StringValue(value) 0260 } 0261 0262 public init(extendedGraphemeClusterLiteral value: ExtendedGraphemeClusterType) { 0263 self = .StringValue(value) 0264 } 0265 0266 public init(stringLiteral value: StringLiteralType) { 0267 self = .StringValue(value) 0268 } 0269 } 0270 0271 extension Json: ArrayLiteralConvertible { 0272 public init(arrayLiteral elements: Json...) { 0273 self = .ArrayValue(elements) 0274 } 0275 } 0276 0277 extension Json: DictionaryLiteralConvertible { 0278 public init(dictionaryLiteral elements: (String, Json)...) { 0279 var object = [String : Json](minimumCapacity: elements.count) 0280 elements.forEach { key, value in 0281 object[key] = value 0282 } 0283 self = .ObjectValue(object) 0284 } 0285 } 0286 0287 0288 0289 0290 0291 // 0292 // JsonSerializer.swift 0293 // JsonSerializer 0294 // 0295 // Created by Fuji Goro on 2014/09/11. 0296 // Copyright (c) 2014 Fuji Goro. All rights reserved. 0297 // License: The MIT License 0298 // 0299 0300 #if os(Linux) 0301 import Glibc 0302 #else 0303 import Darwin 0304 #endif 0305 0306 internal final class JsonDeserializer
JSONSerializer.swift:258 public init(unicodeScalarLiteral value: UnicodeScalarLiteralType) {: Parser { 0307 internal typealias ByteSequence
JSONSerializer.swift:69 return try JsonDeserializer(source.utf8).deserialize()JSONSerializer.swift:73 return try JsonDeserializer(source).deserialize()JSONSerializer.swift:77 return try JsonDeserializer(sequence).deserialize()JSONSerializer.swift:660 extension JsonDeserializer.Char {= [UInt8] 0308 internal typealias Char
JSONSerializer.swift:344 internal required init(_ source: ByteSequence) {= UInt8 0309 0310 // MARK: Public Readable 0311 0312 internal private(set) var lineNumber
JSONSerializer.swift:326 private var currentChar: Char {JSONSerializer.swift:330 private var nextChar: Char {JSONSerializer.swift:370 case Char(ascii: "n"):JSONSerializer.swift:372 case Char(ascii: "t"):JSONSerializer.swift:374 case Char(ascii: "f"):JSONSerializer.swift:376 case Char(ascii: "-"), Char(ascii: "0") ... Char(ascii: "9"):JSONSerializer.swift:376 case Char(ascii: "-"), Char(ascii: "0") ... Char(ascii: "9"):JSONSerializer.swift:376 case Char(ascii: "-"), Char(ascii: "0") ... Char(ascii: "9"):JSONSerializer.swift:378 case Char(ascii: "\""):JSONSerializer.swift:380 case Char(ascii: "{"):JSONSerializer.swift:382 case Char(ascii: "["):JSONSerializer.swift:398 assert(currentChar == Char(ascii: "\""), "points a double quote")JSONSerializer.swift:403 while cur != end && currentChar != Char(ascii: "\"") {JSONSerializer.swift:405 case Char(ascii: "\\"):JSONSerializer.swift:470 case Char(ascii: "0"):JSONSerializer.swift:472 case Char(ascii: "1") ... Char(ascii: "9"):JSONSerializer.swift:472 case Char(ascii: "1") ... Char(ascii: "9"):JSONSerializer.swift:535 assert(currentChar == Char(ascii: "{"), "points \"{\"")JSONSerializer.swift:570 assert(currentChar == Char(ascii: "["), "points \"[\"")JSONSerializer.swift:630 private func isIdentifier(c: Char) -> Bool {JSONSerializer.swift:632 case Char(ascii: "a") ... Char(ascii: "z"):JSONSerializer.swift:632 case Char(ascii: "a") ... Char(ascii: "z"):JSONSerializer.swift:645 case Char(ascii: "\n"):JSONSerializer.swift:660 extension JsonDeserializer.Char {= 1 0313 internal private(set) var columnNumber
JSONSerializer.swift:609 let l = lineNumberJSONSerializer.swift:617 lineNumber = lJSONSerializer.swift:646 lineNumber += 1= 1 0314 0315 // MARK: Source 0316 0317 private let source
JSONSerializer.swift:610 let c = columnNumberJSONSerializer.swift:618 columnNumber = cJSONSerializer.swift:647 columnNumber = 1JSONSerializer.swift:649 columnNumber += 1: [UInt8] 0318 0319 // MARK: State 0320 0321 private var cur
JSONSerializer.swift:327 return source[cur]JSONSerializer.swift:331 return source[cur.successor()]JSONSerializer.swift:345 self.source = source: Int 0322 private let end
JSONSerializer.swift:327 return source[cur]JSONSerializer.swift:331 return source[cur.successor()]JSONSerializer.swift:346 self.cur = source.startIndexJSONSerializer.swift:356 guard cur == end else {JSONSerializer.swift:365 guard cur != end else {JSONSerializer.swift:403 while cur != end && currentChar != Char(ascii: "\"") {JSONSerializer.swift:408 guard cur != end else {JSONSerializer.swift:473 while let value = digitToInt(currentChar) where cur != end {JSONSerializer.swift:486 while let value = digitToInt(currentChar) where cur != end {JSONSerializer.swift:511 while let value = digitToInt(currentChar) where cur != end {JSONSerializer.swift:541 while cur != end && !expect("}") {JSONSerializer.swift:576 LOOP: while cur != end && !expect("]") {JSONSerializer.swift:596 guard cur != end else { return false }JSONSerializer.swift:608 let start = curJSONSerializer.swift:616 cur = start // unreadJSONSerializer.swift:640 assert(cur != end, "out of range")JSONSerializer.swift:641 cur += 1JSONSerializer.swift:642 guard cur != end else { return }JSONSerializer.swift:654 while cur != end && currentChar.isWhitespace {: Int 0323 0324 // MARK: Accessors 0325 0326 private var currentChar
JSONSerializer.swift:347 self.end = source.endIndexJSONSerializer.swift:356 guard cur == end else {JSONSerializer.swift:365 guard cur != end else {JSONSerializer.swift:403 while cur != end && currentChar != Char(ascii: "\"") {JSONSerializer.swift:408 guard cur != end else {JSONSerializer.swift:473 while let value = digitToInt(currentChar) where cur != end {JSONSerializer.swift:486 while let value = digitToInt(currentChar) where cur != end {JSONSerializer.swift:511 while let value = digitToInt(currentChar) where cur != end {JSONSerializer.swift:541 while cur != end && !expect("}") {JSONSerializer.swift:576 LOOP: while cur != end && !expect("]") {JSONSerializer.swift:596 guard cur != end else { return false }JSONSerializer.swift:640 assert(cur != end, "out of range")JSONSerializer.swift:642 guard cur != end else { return }JSONSerializer.swift:654 while cur != end && currentChar.isWhitespace {: Char { 0327 return source[cur] 0328 } 0329 0330 private var nextChar
JSONSerializer.swift:335 return Character(UnicodeScalar(currentChar))JSONSerializer.swift:369 switch currentChar {JSONSerializer.swift:398 assert(currentChar == Char(ascii: "\""), "points a double quote")JSONSerializer.swift:403 while cur != end && currentChar != Char(ascii: "\"") {JSONSerializer.swift:404 switch currentChar {JSONSerializer.swift:420 buffer.append(CChar(bitPattern: currentChar))JSONSerializer.swift:440 let character = UnicodeScalar(currentChar)JSONSerializer.swift:469 switch currentChar {JSONSerializer.swift:473 while let value = digitToInt(currentChar) where cur != end {JSONSerializer.swift:486 while let value = digitToInt(currentChar) where cur != end {JSONSerializer.swift:511 while let value = digitToInt(currentChar) where cur != end {JSONSerializer.swift:535 assert(currentChar == Char(ascii: "{"), "points \"{\"")JSONSerializer.swift:570 assert(currentChar == Char(ascii: "["), "points \"[\"")JSONSerializer.swift:600 if target.utf8Start.memory == currentChar {JSONSerializer.swift:615 if p.memory != currentChar {JSONSerializer.swift:644 switch currentChar {JSONSerializer.swift:654 while cur != end && currentChar.isWhitespace {: Char { 0331 return source[cur.successor()] 0332 } 0333 0334 private var currentSymbol
JSONSerializer.swift:449 while let d = hexToDigit(nextChar) {: Character { 0335 return Character(UnicodeScalar(currentChar)) 0336 } 0337 0338 // MARK: Initializer 0339 0340 internal required convenience init
JSONSerializer.swift:391 throw UnexpectedTokenError("expected \"\(target)\" but \(currentSymbol)", self)JSONSerializer.swift:587 throw UnexpectedTokenError("missing comma (,) (token: \(currentSymbol))", self)<ByteSequence: CollectionType where ByteSequence.Generator.Element == UInt8>(_ sequence: ByteSequence) { 0341 self.init(Array(sequence)) 0342 } 0343 0344 internal required init
JSONSerializer.swift:69 return try JsonDeserializer(source.utf8).deserialize()JSONSerializer.swift:77 return try JsonDeserializer(sequence).deserialize()(_ source: ByteSequence) { 0345 self.source = source 0346 self.cur = source.startIndex 0347 self.end = source.endIndex 0348 } 0349 0350 // MARK: Serialize 0351 0352 internal func deserialize
JSONSerializer.swift:73 return try JsonDeserializer(source).deserialize()JSONSerializer.swift:341 self.init(Array(sequence))() throws -> Json { 0353 let json = try deserializeNextValue() 0354 skipWhitespaces() 0355 0356 guard cur == end else { 0357 throw ExtraTokenError("extra tokens found", self) 0358 } 0359 0360 return json 0361 } 0362 0363 private func deserializeNextValue
JSONSerializer.swift:69 return try JsonDeserializer(source.utf8).deserialize()JSONSerializer.swift:73 return try JsonDeserializer(source).deserialize()JSONSerializer.swift:77 return try JsonDeserializer(sequence).deserialize()() throws -> Json { 0364 skipWhitespaces() 0365 guard cur != end else { 0366 throw InsufficientTokenError("unexpected end of tokens", self) 0367 } 0368 0369 switch currentChar { 0370 case Char(ascii: "n"): 0371 return try parseSymbol("null", Json.NullValue) 0372 case Char(ascii: "t"): 0373 return try parseSymbol("true", Json.BooleanValue(true)) 0374 case Char(ascii: "f"): 0375 return try parseSymbol("false", Json.BooleanValue(false)) 0376 case Char(ascii: "-"), Char(ascii: "0") ... Char(ascii: "9"): 0377 return try parseNumber() 0378 case Char(ascii: "\""): 0379 return try parseString() 0380 case Char(ascii: "{"): 0381 return try parseObject() 0382 case Char(ascii: "["): 0383 return try parseArray() 0384 case let c: 0385 throw UnexpectedTokenError("unexpected token: \(c)", self) 0386 } 0387 } 0388 0389 private func parseSymbol
JSONSerializer.swift:353 let json = try deserializeNextValue()JSONSerializer.swift:542 guard case let .StringValue(key) = try deserializeNextValue() else {JSONSerializer.swift:552 let value = try deserializeNextValue()JSONSerializer.swift:577 let json = try deserializeNextValue()(target: StaticString, @autoclosure _ iftrue: () -> Json) throws -> Json { 0390 guard expect(target) else { 0391 throw UnexpectedTokenError("expected \"\(target)\" but \(currentSymbol)", self) 0392 } 0393 0394 return iftrue() 0395 } 0396 0397 private func parseString
JSONSerializer.swift:371 return try parseSymbol("null", Json.NullValue)JSONSerializer.swift:373 return try parseSymbol("true", Json.BooleanValue(true))JSONSerializer.swift:375 return try parseSymbol("false", Json.BooleanValue(false))() throws -> Json { 0398 assert(currentChar == Char(ascii: "\""), "points a double quote") 0399 advance() 0400 0401 var buffer = [CChar]() 0402 0403 while cur != end && currentChar != Char(ascii: "\"") { 0404 switch currentChar { 0405 case Char(ascii: "\\"): 0406 advance() 0407 0408 guard cur != end else { 0409 throw InvalidStringError("unexpected end of a string literal", self) 0410 } 0411 0412 guard let escapedChar = parseEscapedChar() else { 0413 throw InvalidStringError("invalid escape sequence", self) 0414 } 0415 0416 String(escapedChar).utf8.forEach { 0417 buffer.append(CChar(bitPattern: $0)) 0418 } 0419 default: 0420 buffer.append(CChar(bitPattern: currentChar)) 0421 } 0422 0423 advance() 0424 } 0425 0426 guard expect("\"") else { 0427 throw InvalidStringError("missing double quote", self) 0428 } 0429 0430 buffer.append(0) // trailing nul 0431 0432 guard let string = String.fromCString(buffer) else { 0433 throw InvalidStringError("Unable to parse CString", self) 0434 } 0435 0436 return .StringValue(string) 0437 } 0438 0439 private func parseEscapedChar
JSONSerializer.swift:379 return try parseString()() -> UnicodeScalar? { 0440 let character = UnicodeScalar(currentChar) 0441 0442 // 'u' indicates unicode 0443 guard character == "u" else { 0444 return unescapeMapping[character] ?? character 0445 } 0446 0447 var length = 0 // 2...8 0448 var value: UInt32 = 0 0449 while let d = hexToDigit(nextChar) { 0450 advance() 0451 length += 1 0452 0453 guard length <= 8 else { break } 0454 value <<= 4 0455 value |= d 0456 } 0457 0458 guard length >= 2 else { return nil } 0459 0460 // TODO: validate the value 0461 return UnicodeScalar(value) 0462 } 0463 0464 // number = [ minus ] int [ frac ] [ exp ] 0465 private func parseNumber
JSONSerializer.swift:412 guard let escapedChar = parseEscapedChar() else {() throws -> Json { 0466 let sign = expect("-") ? -1.0 : 1.0 0467 0468 var integer: Int64 = 0 0469 switch currentChar { 0470 case Char(ascii: "0"): 0471 advance() 0472 case Char(ascii: "1") ... Char(ascii: "9"): 0473 while let value = digitToInt(currentChar) where cur != end { 0474 integer = (integer * 10) + Int64(value) 0475 advance() 0476 } 0477 default: 0478 throw InvalidNumberError("invalid token in number", self) 0479 } 0480 0481 var fraction: Double = 0.0 0482 if expect(".") { 0483 var factor = 0.1 0484 var fractionLength = 0 0485 0486 while let value = digitToInt(currentChar) where cur != end { 0487 fraction += (Double(value) * factor) 0488 factor /= 10 0489 fractionLength += 1 0490 0491 advance() 0492 } 0493 0494 guard fractionLength != 0 else { 0495 throw InvalidNumberError("insufficient fraction part in number", self) 0496 } 0497 } 0498 0499 var exponent: Int64 = 0 0500 if expect("e") || expect("E") { 0501 var expSign: Int64 = 1 0502 if expect("-") { 0503 expSign = -1 0504 } else if expect("+") { 0505 // do nothing 0506 } 0507 0508 exponent = 0 0509 0510 var exponentLength = 0 0511 while let value = digitToInt(currentChar) where cur != end { 0512 exponent = (exponent * 10) + Int64(value) 0513 exponentLength += 1 0514 advance() 0515 } 0516 0517 guard exponentLength != 0 else { 0518 throw InvalidNumberError("insufficient exponent part in number", self) 0519 } 0520 0521 exponent *= expSign 0522 } 0523 0524 return .NumberValue(sign * (Double(integer) + fraction) * pow(10, Double(exponent))) 0525 } 0526 0527 private func parseObject
JSONSerializer.swift:377 return try parseNumber()() throws -> Json { 0528 return try getObject() 0529 } 0530 0531 /** 0532 There is a bug in the compiler which makes this function necessary to be called from parseObject 0533 */ 0534 private func getObject
JSONSerializer.swift:381 return try parseObject()() throws -> Json { 0535 assert(currentChar == Char(ascii: "{"), "points \"{\"") 0536 advance() 0537 skipWhitespaces() 0538 0539 var object = [String:Json]() 0540 0541 while cur != end && !expect("}") { 0542 guard case let .StringValue(key) = try deserializeNextValue() else { 0543 throw NonStringKeyError("unexpected value for object key", self) 0544 } 0545 0546 skipWhitespaces() 0547 guard expect(":") else { 0548 throw UnexpectedTokenError("missing colon (:)", self) 0549 } 0550 skipWhitespaces() 0551 0552 let value = try deserializeNextValue() 0553 object[key] = value 0554 0555 skipWhitespaces() 0556 0557 guard !expect("}") else { 0558 break 0559 } 0560 0561 guard expect(",") else { 0562 throw UnexpectedTokenError("missing comma (,)", self) 0563 } 0564 } 0565 0566 return .ObjectValue(object) 0567 } 0568 0569 private func parseArray
JSONSerializer.swift:528 return try getObject()() throws -> Json { 0570 assert(currentChar == Char(ascii: "["), "points \"[\"") 0571 advance() 0572 skipWhitespaces() 0573 0574 var a = Array<Json>() 0575 0576 LOOP: while cur != end && !expect("]") { 0577 let json = try deserializeNextValue() 0578 skipWhitespaces() 0579 0580 a.append(json) 0581 0582 if expect(",") { 0583 continue 0584 } else if expect("]") { 0585 break LOOP 0586 } else { 0587 throw UnexpectedTokenError("missing comma (,) (token: \(currentSymbol))", self) 0588 } 0589 0590 } 0591 0592 return .ArrayValue(a) 0593 } 0594 0595 private func expect
JSONSerializer.swift:383 return try parseArray()(target: StaticString) -> Bool { 0596 guard cur != end else { return false } 0597 0598 if !isIdentifier(target.utf8Start.memory) { 0599 // when single character 0600 if target.utf8Start.memory == currentChar { 0601 advance() 0602 return true 0603 } else { 0604 return false 0605 } 0606 } 0607 0608 let start = cur 0609 let l = lineNumber 0610 let c = columnNumber 0611 0612 var p = target.utf8Start 0613 let endp = p.advancedBy(Int(target.byteSize)) 0614 while p != endp { 0615 if p.memory != currentChar { 0616 cur = start // unread 0617 lineNumber = l 0618 columnNumber = c 0619 return false 0620 } 0621 0622 p += 1 0623 advance() 0624 } 0625 0626 return true 0627 } 0628 0629 // only "true", "false", "null" are identifiers 0630 private func isIdentifier
JSONSerializer.swift:390 guard expect(target) else {JSONSerializer.swift:426 guard expect("\"") else {JSONSerializer.swift:466 let sign = expect("-") ? -1.0 : 1.0JSONSerializer.swift:482 if expect(".") {JSONSerializer.swift:500 if expect("e") || expect("E") {JSONSerializer.swift:500 if expect("e") || expect("E") {JSONSerializer.swift:502 if expect("-") {JSONSerializer.swift:504 } else if expect("+") {JSONSerializer.swift:541 while cur != end && !expect("}") {JSONSerializer.swift:547 guard expect(":") else {JSONSerializer.swift:557 guard !expect("}") else {JSONSerializer.swift:561 guard expect(",") else {JSONSerializer.swift:576 LOOP: while cur != end && !expect("]") {JSONSerializer.swift:582 if expect(",") {JSONSerializer.swift:584 } else if expect("]") {(c: Char) -> Bool { 0631 switch c { 0632 case Char(ascii: "a") ... Char(ascii: "z"): 0633 return true 0634 default: 0635 return false 0636 } 0637 } 0638 0639 private func advance
JSONSerializer.swift:598 if !isIdentifier(target.utf8Start.memory) {() { 0640 assert(cur != end, "out of range") 0641 cur += 1 0642 guard cur != end else { return } 0643 0644 switch currentChar { 0645 case Char(ascii: "\n"): 0646 lineNumber += 1 0647 columnNumber = 1 0648 default: 0649 columnNumber += 1 0650 } 0651 } 0652 0653 private func skipWhitespaces
JSONSerializer.swift:399 advance()JSONSerializer.swift:406 advance()JSONSerializer.swift:423 advance()JSONSerializer.swift:450 advance()JSONSerializer.swift:471 advance()JSONSerializer.swift:475 advance()JSONSerializer.swift:491 advance()JSONSerializer.swift:514 advance()JSONSerializer.swift:536 advance()JSONSerializer.swift:571 advance()JSONSerializer.swift:601 advance()JSONSerializer.swift:623 advance()JSONSerializer.swift:655 advance()() { 0654 while cur != end && currentChar.isWhitespace { 0655 advance() 0656 } 0657 } 0658 } 0659 0660 extension JsonDeserializer.Char { 0661 var isWhitespace
JSONSerializer.swift:354 skipWhitespaces()JSONSerializer.swift:364 skipWhitespaces()JSONSerializer.swift:537 skipWhitespaces()JSONSerializer.swift:546 skipWhitespaces()JSONSerializer.swift:550 skipWhitespaces()JSONSerializer.swift:555 skipWhitespaces()JSONSerializer.swift:572 skipWhitespaces()JSONSerializer.swift:578 skipWhitespaces(): Bool { 0662 let type = self.dynamicType 0663 switch self { 0664 case type.init(ascii: " "), type.init(ascii: "\t"), type.init(ascii: "\r"), type.init(ascii: "\n"): 0665 return true 0666 default: 0667 return false 0668 } 0669 } 0670 } 0671 0672 extension CollectionType { 0673 func prefixUntil(@noescape stopCondition: Generator.Element -> Bool) -> Array<Generator.Element> { 0674 var prefix: [Generator.Element] = [] 0675 for element in self { 0676 guard !stopCondition(element) else { return prefix } 0677 prefix.append(element) 0678 } 0679 return prefix 0680 } 0681 } 0682 0683 0684 0685 0686 0687 0688 0689 0690 0691 // 0692 // JsonSerializer.swift 0693 // JsonSerializer 0694 // 0695 // Created by Fuji Goro on 2014/09/18. 0696 // Copyright (c) 2014年 Fuji Goro. All rights reserved. 0697 // 0698 0699 public protocol JsonSerializer
JSONSerializer.swift:654 while cur != end && currentChar.isWhitespace {{ 0700 init
JSONSerializer.swift:86 private var serializer: JsonSerializer.Type {JSONSerializer.swift:200 public func serialize(serializer: JsonSerializer) -> String {JSONSerializer.swift:704 internal class DefaultJsonSerializer: JsonSerializer {() 0701 func serialize
JSONSerializer.swift:97 return style.serializer.init().serialize(self)(_: Json) -> String 0702 } 0703 0704 internal class DefaultJsonSerializer
JSONSerializer.swift:97 return style.serializer.init().serialize(self)JSONSerializer.swift:201 return serializer.serialize(self): JsonSerializer { 0705 0706 required init
JSONSerializer.swift:89 return DefaultJsonSerializer.selfJSONSerializer.swift:191 return serialize(DefaultJsonSerializer())JSONSerializer.swift:755 internal class PrettyJsonSerializer: DefaultJsonSerializer {() {} 0707 0708 internal func serialize(json: Json) -> String { 0709 switch json { 0710 case .NullValue: 0711 return "null" 0712 case .BooleanValue(let b): 0713 return b ? "true" : "false" 0714 case .NumberValue(let n): 0715 return serializeNumber(n) 0716 case .StringValue(let s): 0717 return escapeAsJsonString(s) 0718 case .ArrayValue(let a): 0719 return serializeArray(a) 0720 case .ObjectValue(let o): 0721 return serializeObject(o) 0722 } 0723 } 0724 0725 func serializeNumber
JSONSerializer.swift:191 return serialize(DefaultJsonSerializer())JSONSerializer.swift:759 super.init()(n: Double) -> String { 0726 if n == Double(Int64(n)) { 0727 return Int64(n).description 0728 } else { 0729 return n.description 0730 } 0731 } 0732 0733 func serializeArray
JSONSerializer.swift:715 return serializeNumber(n)(array: [Json]) -> String { 0734 var string = "[" 0735 string += array 0736 .map { $0.serialize(self) } 0737 .joinWithSeparator(",") 0738 return string + "]" 0739 } 0740 0741 func serializeObject
JSONSerializer.swift:719 return serializeArray(a)(object: [String : Json]) -> String { 0742 var string = "{" 0743 string += object 0744 .map { key, val in 0745 let escapedKey = escapeAsJsonString(key) 0746 let serializedVal = val.serialize(self) 0747 return "\(escapedKey):\(serializedVal)" 0748 } 0749 .joinWithSeparator(",") 0750 return string + "}" 0751 } 0752 0753 } 0754 0755 internal class PrettyJsonSerializer
JSONSerializer.swift:721 return serializeObject(o): DefaultJsonSerializer { 0756 private var indentLevel
JSONSerializer.swift:91 return PrettyJsonSerializer.selfJSONSerializer.swift:195 return serialize(PrettyJsonSerializer())= 0 0757 0758 required init
JSONSerializer.swift:763 indentLevel += 1JSONSerializer.swift:765 indentLevel -= 1JSONSerializer.swift:781 indentLevel += 1JSONSerializer.swift:783 indentLevel -= 1JSONSerializer.swift:803 return Array(1...indentLevel)() { 0759 super.init() 0760 } 0761 0762 override internal func serializeArray(array: [Json]) -> String { 0763 indentLevel += 1 0764 defer { 0765 indentLevel -= 1 0766 } 0767 0768 let indentString = indent() 0769 0770 var string = "[\n" 0771 string += array 0772 .map { val in 0773 let serialized = val.serialize(self) 0774 return indentString + serialized 0775 } 0776 .joinWithSeparator(",\n") 0777 return string + " ]" 0778 } 0779 0780 override internal func serializeObject(object: [String : Json]) -> String { 0781 indentLevel += 1 0782 defer { 0783 indentLevel -= 1 0784 } 0785 0786 let indentString = indent() 0787 0788 var string = "{\n" 0789 string += object 0790 .map { key, val in 0791 let escapedKey = escapeAsJsonString(key) 0792 let serializedValue = val.serialize(self) 0793 let serializedLine = "\(escapedKey): \(serializedValue)" 0794 return indentString + serializedLine 0795 } 0796 .joinWithSeparator(",\n") 0797 string += " }" 0798 0799 return string 0800 } 0801 0802 func indent
JSONSerializer.swift:195 return serialize(PrettyJsonSerializer())() -> String { 0803 return Array(1...indentLevel) 0804 .map { _ in " " } 0805 .joinWithSeparator("") 0806 } 0807 } 0808 0809 0810 0811 0812 0813 0814 0815 // 0816 // ParseError.swift 0817 // JsonSerializer 0818 // 0819 // Created by Fuji Goro on 2014/09/15. 0820 // Copyright (c) 2014 Fuji Goro. All rights reserved. 0821 // 0822 0823 protocol Parser
JSONSerializer.swift:768 let indentString = indent()JSONSerializer.swift:786 let indentString = indent(){ 0824 var lineNumber
JSONSerializer.swift:306 internal final class JsonDeserializer: Parser {JSONSerializer.swift:830 let parser: ParserJSONSerializer.swift:843 init(_ reason: String, _ parser: Parser) {: Int { get } 0825 var columnNumber
JSONSerializer.swift:833 return parser.lineNumber: Int { get } 0826 } 0827 0828 public class ParseError
JSONSerializer.swift:836 return parser.columnNumber: ErrorType, CustomStringConvertible { 0829 public let reason
JSONSerializer.swift:849 public class UnexpectedTokenError: ParseError { }JSONSerializer.swift:851 public class InsufficientTokenError: ParseError { }JSONSerializer.swift:853 public class ExtraTokenError: ParseError { }JSONSerializer.swift:855 public class NonStringKeyError: ParseError { }JSONSerializer.swift:857 public class InvalidStringError: ParseError { }JSONSerializer.swift:859 public class InvalidNumberError: ParseError { }: String 0830 let parser
JSONSerializer.swift:840 return "\(Mirror(reflecting: self))[\(lineNumber):\(columnNumber)]: \(reason)"JSONSerializer.swift:844 self.reason = reason: Parser 0831 0832 public var lineNumber
JSONSerializer.swift:833 return parser.lineNumberJSONSerializer.swift:836 return parser.columnNumberJSONSerializer.swift:845 self.parser = parser: Int { 0833 return parser.lineNumber 0834 } 0835 public var columnNumber
JSONSerializer.swift:840 return "\(Mirror(reflecting: self))[\(lineNumber):\(columnNumber)]: \(reason)": Int { 0836 return parser.columnNumber 0837 } 0838 0839 public var description: String { 0840 return "\(Mirror(reflecting: self))[\(lineNumber):\(columnNumber)]: \(reason)" 0841 } 0842 0843 init(_ reason: String, _ parser: Parser) { 0844 self.reason = reason 0845 self.parser = parser 0846 } 0847 } 0848 0849 public class UnexpectedTokenError
JSONSerializer.swift:840 return "\(Mirror(reflecting: self))[\(lineNumber):\(columnNumber)]: \(reason)": ParseError { } 0850 0851 public class InsufficientTokenError
JSONSerializer.swift:385 throw UnexpectedTokenError("unexpected token: \(c)", self)JSONSerializer.swift:391 throw UnexpectedTokenError("expected \"\(target)\" but \(currentSymbol)", self)JSONSerializer.swift:548 throw UnexpectedTokenError("missing colon (:)", self)JSONSerializer.swift:562 throw UnexpectedTokenError("missing comma (,)", self)JSONSerializer.swift:587 throw UnexpectedTokenError("missing comma (,) (token: \(currentSymbol))", self): ParseError { } 0852 0853 public class ExtraTokenError
JSONSerializer.swift:366 throw InsufficientTokenError("unexpected end of tokens", self): ParseError { } 0854 0855 public class NonStringKeyError
JSONSerializer.swift:357 throw ExtraTokenError("extra tokens found", self): ParseError { } 0856 0857 public class InvalidStringError
JSONSerializer.swift:543 throw NonStringKeyError("unexpected value for object key", self): ParseError { } 0858 0859 public class InvalidNumberError
JSONSerializer.swift:409 throw InvalidStringError("unexpected end of a string literal", self)JSONSerializer.swift:413 throw InvalidStringError("invalid escape sequence", self)JSONSerializer.swift:427 throw InvalidStringError("missing double quote", self)JSONSerializer.swift:433 throw InvalidStringError("Unable to parse CString", self): ParseError { } 0860 0861 0862 0863 0864 0865 0866 0867 // 0868 // StringUtils.swift 0869 // JsonSerializer 0870 // 0871 // Created by Fuji Goro on 2014/09/15. 0872 // Copyright (c) 2014 Fuji Goro. All rights reserved. 0873 // 0874 0875 let unescapeMapping
JSONSerializer.swift:478 throw InvalidNumberError("invalid token in number", self)JSONSerializer.swift:495 throw InvalidNumberError("insufficient fraction part in number", self)JSONSerializer.swift:518 throw InvalidNumberError("insufficient exponent part in number", self): [UnicodeScalar: UnicodeScalar] = [ 0876 "t": "\t", 0877 "r": "\r", 0878 "n": "\n", 0879 ] 0880 0881 let escapeMapping
JSONSerializer.swift:444 return unescapeMapping[character] ?? character: [Character : String] = [ 0882 "\r": "\\r", 0883 "\n": "\\n", 0884 "\t": "\\t", 0885 "\\": "\\\\", 0886 "\"": "\\\"", 0887 0888 "\u{2028}": "\\u2028", // LINE SEPARATOR 0889 "\u{2029}": "\\u2029", // PARAGRAPH SEPARATOR 0890 0891 // XXX: countElements("\r\n") is 1 in Swift 1.0 0892 "\r\n": "\\r\\n", 0893 ] 0894 0895 let hexMapping
JSONSerializer.swift:930 .map { escapeMapping[$0] ?? String($0) }: [UnicodeScalar : UInt32] = [ 0896 "0": 0x0, 0897 "1": 0x1, 0898 "2": 0x2, 0899 "3": 0x3, 0900 "4": 0x4, 0901 "5": 0x5, 0902 "6": 0x6, 0903 "7": 0x7, 0904 "8": 0x8, 0905 "9": 0x9, 0906 "a": 0xA, "A": 0xA, 0907 "b": 0xB, "B": 0xB, 0908 "c": 0xC, "C": 0xC, 0909 "d": 0xD, "D": 0xD, 0910 "e": 0xE, "E": 0xE, 0911 "f": 0xF, "F": 0xF, 0912 ] 0913 0914 let digitMapping
JSONSerializer.swift:945 return hexMapping[UnicodeScalar(b)]: [UnicodeScalar:Int] = [ 0915 "0": 0, 0916 "1": 1, 0917 "2": 2, 0918 "3": 3, 0919 "4": 4, 0920 "5": 5, 0921 "6": 6, 0922 "7": 7, 0923 "8": 8, 0924 "9": 9, 0925 ] 0926 0927 extension String { 0928 public var escapedJsonString
JSONSerializer.swift:941 return digitMapping[UnicodeScalar(b)]: String { 0929 let mapped = characters 0930 .map { escapeMapping[$0] ?? String($0) } 0931 .joinWithSeparator("") 0932 return "\"" + mapped + "\"" 0933 } 0934 } 0935 0936 public func escapeAsJsonString
JSONSerializer.swift:937 return source.escapedJsonString(source : String) -> String { 0937 return source.escapedJsonString 0938 } 0939 0940 func digitToInt
JSONSerializer.swift:717 return escapeAsJsonString(s)JSONSerializer.swift:745 let escapedKey = escapeAsJsonString(key)JSONSerializer.swift:791 let escapedKey = escapeAsJsonString(key)(b: UInt8) -> Int? { 0941 return digitMapping[UnicodeScalar(b)] 0942 } 0943 0944 func hexToDigit
JSONSerializer.swift:473 while let value = digitToInt(currentChar) where cur != end {JSONSerializer.swift:486 while let value = digitToInt(currentChar) where cur != end {JSONSerializer.swift:511 while let value = digitToInt(currentChar) where cur != end {(b: UInt8) -> UInt32? { 0945 return hexMapping[UnicodeScalar(b)] 0946 } 0947 0948
JSONSerializer.swift:449 while let d = hexToDigit(nextChar) {