diff --git a/Sources/Turf/JSON.swift b/Sources/Turf/JSON.swift index 4b92b53..b3d0fe9 100644 --- a/Sources/Turf/JSON.swift +++ b/Sources/Turf/JSON.swift @@ -103,11 +103,11 @@ extension JSONValue: RawRepresentable { /// can succeed when the NSNumber's value is 0 or 1 even /// when its objCType is not 'c'. self = .boolean(boolean) - } else if let rawArray = rawValue as? JSONArray.RawValue, - let array = JSONArray(rawValue: rawArray) { + } else if let rawArray = rawValue as? JSONArray.TurfRawValue, + let array = JSONArray(turfRawValue: rawArray) { self = .array(array) - } else if let rawObject = rawValue as? JSONObject.RawValue, - let object = JSONObject(rawValue: rawObject) { + } else if let rawObject = rawValue as? JSONObject.TurfRawValue, + let object = JSONObject(turfRawValue: rawObject) { self = .object(object) } else { return nil @@ -123,9 +123,9 @@ extension JSONValue: RawRepresentable { case let .number(value): return value case let .object(value): - return value.rawValue + return value.turfRawValue case let .array(value): - return value.rawValue + return value.turfRawValue } } } @@ -135,14 +135,14 @@ extension JSONValue: RawRepresentable { */ public typealias JSONArray = [JSONValue?] -extension JSONArray: RawRepresentable { - public typealias RawValue = [Any?] - - public init?(rawValue values: RawValue) { +extension JSONArray { + public typealias TurfRawValue = [Any?] + + public init?(turfRawValue values: TurfRawValue) { self = values.map(JSONValue.init(rawValue:)) } - - public var rawValue: RawValue { + + public var turfRawValue: TurfRawValue { return map { $0?.rawValue } } } @@ -152,14 +152,14 @@ extension JSONArray: RawRepresentable { */ public typealias JSONObject = [String: JSONValue?] -extension JSONObject: RawRepresentable { - public typealias RawValue = [String: Any?] +extension JSONObject { + public typealias TurfRawValue = [String: Any?] - public init?(rawValue: RawValue) { - self = rawValue.mapValues { $0.flatMap(JSONValue.init(rawValue:)) } + public init?(turfRawValue: TurfRawValue) { + self = turfRawValue.mapValues { $0.flatMap(JSONValue.init(rawValue:)) } } - public var rawValue: RawValue { + public var turfRawValue: TurfRawValue { return mapValues { $0?.rawValue } } } diff --git a/Tests/TurfTests/JSONTests.swift b/Tests/TurfTests/JSONTests.swift index e1dc412..5a18080 100644 --- a/Tests/TurfTests/JSONTests.swift +++ b/Tests/TurfTests/JSONTests.swift @@ -37,15 +37,15 @@ class JSONTests: XCTestCase { XCTAssertNil(JSONValue(rawValue: NSNull())) XCTAssertEqual(JSONValue(rawValue: [NSNull()]), .array([nil])) - XCTAssertEqual(JSONArray(rawValue: [NSNull()]), [nil]) + XCTAssertEqual(JSONArray(turfRawValue: [NSNull()]), [nil]) XCTAssertEqual(JSONValue(rawValue: ["NSNull": NSNull()]), .object(["NSNull": nil])) - XCTAssertEqual(JSONObject(rawValue: ["NSNull": NSNull()]), ["NSNull": nil]) + XCTAssertEqual(JSONObject(turfRawValue: ["NSNull": NSNull()]), ["NSNull": nil]) XCTAssertNil(JSONValue(rawValue: Set(["Get"]))) XCTAssertEqual(JSONValue(rawValue: [Set(["Get"])]), .array([nil])) - XCTAssertEqual(JSONArray(rawValue: [Set(["Get"])]), [nil]) + XCTAssertEqual(JSONArray(turfRawValue: [Set(["Get"])]), [nil]) XCTAssertEqual(JSONValue(rawValue: ["set": Set(["Get"])]), .object(["set": nil])) - XCTAssertEqual(JSONObject(rawValue: ["set": Set(["Get"])]), ["set": nil]) + XCTAssertEqual(JSONObject(turfRawValue: ["set": Set(["Get"])]), ["set": nil]) } func testLiterals() throws { diff --git a/Turf.xcodeproj/project.pbxproj b/Turf.xcodeproj/project.pbxproj index 3763a1e..37b8813 100644 --- a/Turf.xcodeproj/project.pbxproj +++ b/Turf.xcodeproj/project.pbxproj @@ -515,7 +515,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; INFOPLIST_FILE = Sources/Turf/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; @@ -581,7 +581,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; INFOPLIST_FILE = Sources/Turf/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MACOSX_DEPLOYMENT_TARGET = 10.13; MTL_ENABLE_DEBUG_INFO = NO; SUPPORTED_PLATFORMS = "iphonesimulator iphoneos macosx appletvos appletvsimulator watchsimulator watchos";