fix case with nsdata in json
This commit is contained in:
parent
520a765c22
commit
d8c8b4941e
@ -111,6 +111,8 @@ class SocketTestCases: NSObject {
|
|||||||
|
|
||||||
static func testJSONWithBuffer(abstractSocketSend:SocketSendFunction) {
|
static func testJSONWithBuffer(abstractSocketSend:SocketSendFunction) {
|
||||||
let testName = "testJSONWithBuffer"
|
let testName = "testJSONWithBuffer"
|
||||||
|
let data = "0".dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)!
|
||||||
|
|
||||||
func didGetResult(result:NSArray?, ack:AckEmitter?) {
|
func didGetResult(result:NSArray?, ack:AckEmitter?) {
|
||||||
if let json = result?.firstObject as? NSDictionary {
|
if let json = result?.firstObject as? NSDictionary {
|
||||||
XCTAssertEqual((json.valueForKey("testString")! as! String), "test")
|
XCTAssertEqual((json.valueForKey("testString")! as! String), "test")
|
||||||
@ -123,7 +125,7 @@ class SocketTestCases: NSObject {
|
|||||||
XCTFail("Should have NSDictionary as result")
|
XCTFail("Should have NSDictionary as result")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let json = ["name": "test", "testArray": ["hallo"], "nestedTest": ["test": "test"], "number": 15]
|
let json = ["name": "test", "testArray": ["hallo"], "nestedTest": ["test": "test"], "number": 15, "buf": data]
|
||||||
|
|
||||||
abstractSocketSend(testName: testName, emitData: json, callback: didGetResult)
|
abstractSocketSend(testName: testName, emitData: json, callback: didGetResult)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -281,12 +281,14 @@ private extension SocketPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return arr
|
return arr
|
||||||
} else if let dict = data as? NSMutableDictionary {
|
} else if let dict = data as? NSDictionary {
|
||||||
|
let mutDict = NSMutableDictionary(dictionary: dict)
|
||||||
|
|
||||||
for (key, value) in dict {
|
for (key, value) in dict {
|
||||||
dict[key as! NSCopying] = shred(value, binary: &binary)
|
mutDict[key as! NSCopying] = shred(value, binary: &binary)
|
||||||
}
|
}
|
||||||
|
|
||||||
return dict
|
return mutDict
|
||||||
} else {
|
} else {
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user