-JSONValue 失败
我的 JSON 解析代码:
// Store incoming data into a string
NSString *jsonString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
// Create a dictionary from the JSON string
NSDictionary *results = [jsonString JSONValue];
NSLog(@"%@",jsonString);
当我调试代码时,我得到 jsonString 但得到 0 个键值对。 错误为:
-JSONValue 失败。错误跟踪是:( “错误域=org.brautaset.JSON.ErrorDomain代码=5\“未转义的控制字符'0x0'\”UserInfo=0x4d2e030 {NSLocalizedDescription=未转义的控制字符'0x0'}”, “错误域 = org.brautaset.JSON.ErrorDomain 代码 = 3 \“密钥所需的对象值:id \” UserInfo = 0x4d2e130 {NSUnderlyingError = 0x4d2e090 \“未转义的控制字符'0x0'\”,NSLocalizedDescription=Object 键的预期值:id}”, “Error Domain=org.brautaset.JSON.ErrorDomain Code=3 \“解析数组时的预期值\” UserInfo=0x4d2e180 {NSUnderlyingError=0x4d2e110 \“键所需的对象值:id \”, NSLocalizedDescription=解析数组时的预期值}", “错误域 = org.brautaset.JSON.ErrorDomain 代码 = 3 \“键所需的对象值:预测\” UserInfo = 0x4d2e250 {NSUnderlyingError=0x4d2e210 \“解析数组时的预期值\”, NSLocalizedDescription=键预期的对象值:预测}"
My code for JSON parsing:
// Store incoming data into a string
NSString *jsonString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
// Create a dictionary from the JSON string
NSDictionary *results = [jsonString JSONValue];
NSLog(@"%@",jsonString);
When I debug the code I am getting the jsonString but getting 0 key value pairs.
And Error as:
-JSONValue failed. Error trace is: (
"Error Domain=org.brautaset.JSON.ErrorDomain Code=5 \"Unescaped control character '0x0'\" UserInfo=0x4d2e030
{NSLocalizedDescription=Unescaped control character '0x0'}",
"Error Domain=org.brautaset.JSON.ErrorDomain Code=3 \"Object value expected for key: id\" UserInfo=0x4d2e130 {NSUnderlyingError=0x4d2e090
\"Unescaped control character '0x0'\", NSLocalizedDescription=Object
value expected for key: id}",
"Error Domain=org.brautaset.JSON.ErrorDomain Code=3 \"Expected value while parsing array\" UserInfo=0x4d2e180
{NSUnderlyingError=0x4d2e110 \"Object value expected for key: id\",
NSLocalizedDescription=Expected value while parsing array}",
"Error Domain=org.brautaset.JSON.ErrorDomain Code=3 \"Object value expected for key: predictions\" UserInfo=0x4d2e250
{NSUnderlyingError=0x4d2e210 \"Expected value while parsing array\",
NSLocalizedDescription=Object value expected for key: predictions}"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 JSON 验证器 验证您的字符串是否是有效的 JSON。
Use JSON validator to validate your string whether that is a valid JSON.