我得到響應:錯誤雖然解析JSON字符串響應隨目標C
{"response":{"id":"R1","cmd":[{"batchSize":50,"startRow":0,"name":"doLogin","result":"OK","attributes":[{"name":"businessName","type":"String"},{"name":"objId","type":"Long"},{"name":"businessType","type":"String"},{"name":"firstName","type":"String"},{"name":"businessName","type":"String"},{"name":"objId","type":"Long"},{"name":"businessType","type":"String"},{"name":"firstName","type":"String"}],"records":[["businessName\":\"Palo Alto Egg - Distributor","objId\":\"200","businessType\":\"D","firstName\":\"System"],["businessName\":\"Palo Alto Egg - Distributor","objId\":\"200","businessType\":\"D","firstName\":\"System"],["businessName\":\"Palo Alto Egg - Distributor","objId\":\"200","businessType\":\"D","firstName\":\"System"],["businessName\":\"Palo Alto Egg - Distributor","objId\":\"200","businessType\":\"D","firstName\":\"System"]]}]}}
現在的問題是,....... 的NSDictionary * JSON = [NSJSONSerialization JSONObjectWithData:(NSData的*)obj選項:kNilOptions錯誤:&錯誤];
NSDictionary *first = [json objectForKey:@"response"];
NSArray *second = [first objectForKey:@"cmd"];
NSArray *attribute_array = [[second objectAtIndex:0] objectForKey:@"result"];
NSLog(@"Resultttttttttt=%@",attribute_array);
//Value of Result
NSString *resultVal = [NSString stringWithFormat:@"%@",attribute_array];
NSArray *record_array = [[second objectAtIndex:0] objectForKey:@"records"];
NSLog(@"Resultttttttttt Nisarg = %@",[[record_array objectAtIndex:0] objectForKey:@"firstName\\"]);
在當我試圖爲重點的firstName獲取價值它給錯誤,因爲結構是這樣「名字\」,而不是關鍵「名字」的所以任何的最後一句話建議與「名字\」重點解析字符串....
顯示響應反序列化後的JSON字典。 – chandu