尝试在 xcode 中解析 json 数据时遇到了一个大问题。我实际上已经尝试过两个不同的解析器,但它仍然返回一个错误的 json。有人可以帮忙吗?
要解析的字符串(称为 jsonResp)等于:
{
"error":false,
"errorMessage":null,
"debugMessage":null,
"count":1,
"list":"links",
"data":[
{
"date":"Jeudi \u00e0 00:00:00",
"type":"friend",
"picture":"http://graph.facebook.com/22222222/picture? type=square",
"name":"Etouda Gaudo",
"ink_id":"1",
"chat_id":"1",
"count":"1",
"last_message":"CoUcou"
}
]
}
要解析的字符串等于:
NSData *jsonData = [jsonResp dataUsingEncoding:NSUTF8StringEncoding];
NSError *error = nil;
NSDictionary *dictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&error];
NSLog(@"dictionary %@", dictionary);
然后我得到了字典 NSLog 的以下结果:
dictionary {
count = 1;
data = (
{
"chat_id" = 1;
count = 1;
date = "Jeudi \U00e0 00:00:00";
"ink_id" = 1;
"last_message" = CoUcou;
name = "Test name";
picture = "http://graph.facebook.com/22222222/picture?type=square";
type = friend;
}
);
debugMessage = "<null>";
error = 0;
errorMessage = "<null>";
list = links;
我不明白为什么 "不见了...... 有没有人有解决办法。
提前致谢。
最佳答案
NSLog只是供开发者查看的打印表示,它是类实例调用description
方法的结果。引号仅在没有引号的情况下添加,例如带有嵌入空格的字符串。要验证 JSON 是否已正确解析,请使用代码对其进行验证。
关于iphone - Json 解析问题 iOS : missing ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7311318/