【发布时间】:2012-08-30 19:07:50
【问题描述】:
嗨,我有这个字符串 { "data": [ { "name": "Lorena Trujillo", "id": "500144123" }, { "name": "George Arcila", "id": "520311359" }, { "name": "Laura Victoria Mu\u00f1oz Rincon", "id": "528543677" }, { "name": "Camilo Andres Santacoloma Mejia", "id": "529547832" }],"paging" :{ “下一个”: “https://graph.facebook.com/537223119/friends?access_token=AAAAAAITEghMBAI7cZBdbAHt3ZC24esi4ZA6O6kFdwU1H0ekDmGQGRZCUZAVW3T6W6fzg50jHsdfsdfsfdsfdsfzdixf1RrTFLzV96ZBWXAZDZD&limit=5000&offset=5000&__after_id=1000456456455”}
}
你需要提取 [ 和 ] 之间的子字符串,我使用下一个代码
NSRange startRange = [strFriends rangeOfString:@"["];
NSRange endRange = [strFriends rangeOfString:@"]"];
NSString *formData = [strFriends substringWithRange:NSMakeRange(startRange.location,endRange.location)];
NSLog(@"this is the data %@",formData);
结果是
[ { "name": "Lorena Trujillo", "id": "500144123" }, { "name": "George Arcila", "id": "520311359" }, { "name": "Laura Victoria Mu\u00f1oz Rincon", "id": "528543677" }, { "name": "Camilo Andres Santacoloma Mejia", "id": "529547832" }],"pagin
知道为什么最后这些字符会出现,“非常感谢页面
【问题讨论】:
-
听起来你需要一个 JSON 解析器。
标签: objective-c ios nsstring substring nsrange