我在 Android中很容易做到,但我很少失去如何在iOs中做到这一点. 我的json就像: [{"name":"qwe","whatever1":"asd","whatever2":"zxc"}, {"name":"fgh","whatever1":"asd","whatever2":"zxc"}] 如果我做: NSData *jsonData
我的json就像:
[{"name":"qwe","whatever1":"asd","whatever2":"zxc"}, {"name":"fgh","whatever1":"asd","whatever2":"zxc"}]
如果我做:
NSData *jsonData = [data dataUsingEncoding:NSUTF32BigEndianStringEncoding]; rows = [NSJSONSerialization JSONObjectWithData: jsonData options: NSJSONReadingMutableContainers error: &error];
在行中可以访问吗?
NSString *name = [[rows objectAtIndex:0] [objectForKey:@s"name"]];
或者我是怎么做到的?谢谢.
FINALLY NSString * name = [[rows objectAtIndex:0] objectForKey:@“name”]];作品! :d
我认为这会有用,但是你想要:NSString *name = [[rows objectAtIndex:0] objectForKey:@"name"];
(删除无关的方括号并使用@“name”作为字符串文字).
但是,输入JSON真的是UTF-32格式吗?