【问题标题】:parse json file in objective-c在objective-c中解析json文件
【发布时间】:2012-07-29 15:31:37
【问题描述】:

我有这个 json 链接Json_link

我如何获得 (17 : 00) 和 (Amberg) 和 (Aubstadt) 值。并提前致谢。

【问题讨论】:

  • JSON数据主要包含HTML数据。您感兴趣的值位于 HTML 数据中的 a 中。提取出来会很有趣...
  • 正如评论已经说过的那样 - 您想要的数据位于 JSON 中嵌入的 html 中。你只需要得到它并使用正则表达式或(最好)xml解析器来获取你想要的数据。

标签: iphone objective-c xcode sbjson


【解决方案1】:

在您的项目中添加一个 JSON 库并将代码放在解析文件中

NSArray* latestLoans = [(NSDictionary*)[responseString JSONValue] objectForKey:@"commands"];
[responseString release];

NSLog(@"%@",[[latestLoans objectAtIndex:0] objectForKey:@"name"]);
NSLog(@"%@",[[[latestLoans objectAtIndex:0] objectForKey:@"parameters"] objectForKey:@"container"]);
NSLog(@"%@",[[[latestLoans objectAtIndex:0] objectForKey:@"parameters"] objectForKey:@"content"]);
NSLog(@"%@",[[[latestLoans objectAtIndex:0] objectForKey:@"parameters"] objectForKey:@"position"]);



NSLog(@"%@",[[latestLoans objectAtIndex:1] objectForKey:@"name"]);
NSLog(@"%@",[[[[latestLoans objectAtIndex:1] objectForKey:@"parameters"] objectForKey:@"params"] objectForKey:@"date"]);
NSLog(@"%@",[[[[latestLoans objectAtIndex:1] objectForKey:@"parameters"] objectForKey:@"params"] objectForKey:@"display"]);
NSLog(@"%@",[[[[latestLoans objectAtIndex:1] objectForKey:@"parameters"] objectForKey:@"params"] objectForKey:@"timestamp"]);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-31
    • 1970-01-01
    • 1970-01-01
    • 2013-06-06
    • 2011-08-31
    • 1970-01-01
    相关资源
    最近更新 更多