ios - Obj-C get JSON key name -
hi trying create link between php , ios, , using json. although json array strange, not creator, in closed api, cannot change it.
the json looks this:
{"success":true,"errors":[],"data":{"servers":{"6":"name here"}}}
the 6 id of server, , other 1 name.
as can see key id , value name, how id in objective-c? know how receive server name, need find server id.
here current code:
nsdictionary *json = [[nsdictionary alloc] init]; nserror *error; json = [nsjsonserialization jsonobjectwithdata:_responsedata options:kniloptions error:&error]; nsdictionary *test = [datadict objectforkey:@"servers"] nslog(@"%@", [test objectforkey:@"6"]); // server name (id of server 6)
_responsedata
json data received php script.
you like:
[test enumeratekeysandobjectsusingblock:^(nsstring* serverid, nsstring *servername, bool *stop) { // process data here. }];
Comments
Post a Comment