我对Objective-c有点新。我试图解析JSON数据,看起来像这是在一个单一的数组。下面将Json NSDictionary项目转换为字符串 - Objective C
[{"id":"3672","name":"TestName","color":"red","cost":456","date":"0000-00-00 00:00:00"}]
是代码的目标C部分
FullUrl=[NSString stringWithFormat:@"http://mywebsite.com?user=%@",uservalue];
NSString *absoluteURl=[NSString string];
absoluteURl=[self URLEncodeString:FullUrl];
NSURL *url=[[NSURL alloc]initWithString:absoluteURl];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
NSData *data = [NSURLConnection sendSynchronousRequest:request
returningResponse:nil error:nil];
NSData *jsonData = [data dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *parseJson = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:nil]
现在我想知道我怎么可以采取每个键值为从parseJson一个字符串?比如我想的名字值到“字符串名称”等,
,当我把在线路的NSDictionary断点* parseJson =,并采取了光标它parseJson节目,如
<__NSCFArray 0x1dddb670>(
{
name = "TestName";
id = 3672;
color = red;
cost = "456";
date = "0000-00-00 00:00:00";
}
)
因此,这意味着,JSON解析是在我的代码中工作正常吗?与json webservice Items订单相比,为什么订单不正确?
谢谢,我明白了。 – 2014-10-04 18:14:32