NSJSONSerialization给我错误“重复密钥". [英] NSJSONSerialization gives me error "Duplicate key"
问题描述
我从家用控制设备请求JSON响应:
I request a JSON response from a home controlling device:
NSData* responseData = [NSData dataWithContentsOfURL:url];
responseData
中的JSON数据完整且有效.但是,如果我尝试
The JSON data in responseData
is complete and valid. However, if I try
NSDictionary* dict = [NSJSONSerialization
JSONObjectWithData:responseData
options:kNilOptions
error:&error];
NSLog("Error: %@", error);
它给了我以下错误:
错误:错误域= NSCocoaErrorDomain代码= 3840操作无法完成.(可可错误3840.)"(字符0周围的对象的重复键.)UserInfo = 0x6a8b8e0 {NSDebugDescription =字符周围的对象的重复键0.}
Error: Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Duplicate key for object around character 0.) UserInfo=0x6a8b8e0 {NSDebugDescription=Duplicate key for object around character 0.}
我搜索了网络,但到目前为止找不到任何有用的信息.
I searched the web but couldn't find anything helpful so far.
编辑:JSON响应时间很长,因此请不要在此处发布它,这里.
Edit: The JSON response it quite long, so instead of posting it here, please find it here.
推荐答案
将JSON粘贴到 http: //jsonformat.com/-也许您发现了Apple bug?尝试验证的另一种方法是使用第三方iOS库,看看它是否给您同样的错误?说, TouchJSON ?
It looks like the JSON is fine by pasting it into http://jsonformat.com/ - maybe you found an Apple bug? Another way to try and validate would be to use a third-party iOS library and see if it gives you the same error? Say, TouchJSON?
这篇关于NSJSONSerialization给我错误“重复密钥".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!