0

如何访问组的内容?

目前,我可以访问书签和博客。

我认为组后的两个字符会产生阅读问题。

这是从 json 文件中选择数据以显示数据的代码

 NSDictionary *feed = [jsonObjects objectForKey:@"object"];
 NSArray *entries = [feed objectForKey:@"bookmarks"];

for (NSDictionary *item in entries)

{
 [item objectForKey:@"SomeDataIdentifierOfBookmarks"]
}

这是 NSMutableArray 读取的 JSON 文件

编辑真实数据 JSON

{"object": {"blog":[{"guid":181,"type":"object","subtype":"4","time_created":"","time_updated":"","container_guid ":"180","owner_guid":"180","site_guid":"1","title":"ugyt","description":"scsa","url":"http://s210678217.onlinehome .fr/blog/view/181/ugg-sito-ufficiale-italiavyt"}], "书签":[{"guid":82,"type":"object","subtype":"9","time_created ":"1372072736","time_updated":"1372072910","container_guid":"81","owner_guid":"33","site_guid":"1","title":“互联网-”,“描述”:“”,“url”:“hr”},{“guid”:75,“type”:“object”,“subtype”:“9”,“time_created”:“1371728924 ","time_updated":"1371728924","container_guid":"64","owner_guid":"52","site_guid":"1","title":"du","description":"1","title":"du","description":"1","title":"du","description":"

p>","url":"htts"}, {"guid":64,"type":"group","subtype":"0","time_created":"1371728148","time_updated":"1372068044 ","container_guid":"33","owner_guid":"33","site_guid":"1","name":"yvelines","description":"

乐。</p>","url":"http://ses"} ] ] }

谢谢

4

1 回答 1

1

这不是接近有效的 JSON。在担心解包数据的代码之前,请使用http://jsonlint.com确保您有有效的输入。您有多个未闭合的数组(“[”字符开始一个数组,“]”结束它,并且至少缺少一个逗号(在“书签”之前)。很难判断这个 JSON 有什么问题,因为有足够多的错误,意图不明确。

您用于访问内容的代码大部分都很好,除了“SomeDataIdentifierOfBookmarks”不是您的 JSON 中的键——我认为您的意思是它将被替换为实际值。

编辑:您粘贴的实际 JSON 试图用方括号而不是花括号来关闭“对象”对象。jsonlint 会迅速解决这些错误。

于 2013-08-21T21:06:20.603 回答