我對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