使用SBJSON在Objective-C中解析JSON [英] Parse JSON in Objective-C with SBJSON

查看:109
本文介绍了使用SBJSON在Objective-C中解析JSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想使用SBJSON框架在Objective-C中解析此JSON字符串,并检索三个数据单元:

I just want to parse this JSON string in Objective-C using the SBJSON framework, and retrieve the three units of data:

{"x":"197","y":"191","text":"this is a string"}

这怎么办?

推荐答案

NSString * jsonString = @"{\"x\":\"197\",\"y\":\"191\",\"text\":\"this is a string\"}";
SBJSON *jsonParser = [[SBJSON alloc] init];
NSDictionary * dictionary = [jsonParser objectWithString:jsonString];
NSLog(@"x is %@",[dictionary objectForKey:@"x"]);
[jsonParser release];

这篇关于使用SBJSON在Objective-C中解析JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆