求解析这个JSON,求Object-C详细代码

qq_37227501 2017-01-01 11:27:37

{\"id\":2381,\"date\":\"2015-12-13T23:03:37\",\"date_gmt\":\"2015-12-13T15:03:37\",\"guid\":{\"rendered\":\"http://www.test.net/?p=2381\"},\"modified\":\"2015-12-13T23:07:55\",\"modified_gmt\":\"2015-12-13T15:07:55\",\"title\":{\"rendered\":\"Android:第一个Android APP发布\"},\"content\":{\"rendered\":\"你的人生永远不会辜负你的。那些转错的弯,那些走错的路,那些流下的泪水,那些滴下的汗水,那些留下的伤痕,全都让你成为独一无二的自己。by 朱学恒\",\"protected\":false},\"excerpt\":{\"rendered\":\"第一个.. 开源了APP的所有代码[访问地址]. 初试牛刀,学了这么久的Android.总算在磕磕绊绊中完成了 […]\"},\"author\":1,\"featured_media\":0,\"comment_status\":\"open\",\"ping_status\":\"open\",\"wp:term\":[{\"taxonomy\":\"category\",\"href\":\"http://www.text.net/wp-json/wp/v2/categories?post=2381\"},{\"taxonomy\":\"post_tag\",\"href\":\"http://www.text.net/wp-json/wp/v2/tags?post=2381\"}],\"curies\":[{\"name\":\"wp\",\"href\":\"https://api.w.org/{rel}\"}]}}




谢谢。。。
...全文
331 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
scribbler 2017-01-04
  • 打赏
  • 举报
回复

NSString * string = @"{\"id\":2381,\"date\":\"2015-12-13T23:03:37\",\"date_gmt\":\"2015-12-13T15:03:37\",\"guid\":{\"rendered\":\"http://www.test.net/?p=2381\"},\"modified\":\"2015-12-13T23:07:55\",\"modified_gmt\":\"2015-12-13T15:07:55\",\"title\":{\"rendered\":\"Android:第一个Android APP发布\"},\"content\":{\"rendered\":\"你的人生永远不会辜负你的。那些转错的弯,那些走错的路,那些流下的泪水,那些滴下的汗水,那些留下的伤痕,全都让你成为独一无二的自己。by 朱学恒\",\"protected\":false},\"excerpt\":{\"rendered\":\"第一个.. 开源了APP的所有代码[访问地址]. 初试牛刀,学了这么久的Android.总算在磕磕绊绊中完成了 […]\"},\"author\":1,\"featured_media\":0,\"comment_status\":\"open\",\"ping_status\":\"open\",\"wp:term\":[{\"taxonomy\":\"category\",\"href\":\"http://www.text.net/wp-json/wp/v2/categories?post=2381\"},{\"taxonomy\":\"post_tag\",\"href\":\"http://www.text.net/wp-json/wp/v2/tags?post=2381\"}],\"curies\":[{\"name\":\"wp\",\"href\":\"https://api.w.org/{rel}\"}]}";
    
NSDictionary * dict = [self parseJsonString:string];
NSLog(@"%@",dict);

- (id) parseJsonString:(NSString*)jsonString
{
    if( jsonString==nil )
        return nil;
    
    NSData * parseData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    id jsonObject = [NSJSONSerialization JSONObjectWithData:parseData options:NSJSONReadingMutableLeaves error:nil];
    
    return jsonObject;
}
sailip 2017-01-03
  • 打赏
  • 举报
回复
+(NSDictionary*)dictionaryWithJsonString:(NSString *)string { if (isBlankString(string)) { return nil; } return [NSDictionary dictionaryWithJsonData:[string dataUsingEncoding:NSUTF8StringEncoding]]; } 把你这个字符串传传入这个方法

29,027

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧