このJSON ツリーがあり、配列をカテゴリ キーでグループ化する必要があります。(この例では、""、"1"、"2"、"3" および "serf" はカテゴリの値の名前です。) NSJSONSerialization を使用して JSON をシリアル化していますが、希望どおりに解析できません。これが私のコードの一部です:
NSData *data2=[NSData dataWithContentsOfURL:url2];
result2=[NSJSONSerialization JSONObjectWithData: data2
options: NSJSONReadingMutableContainers
error: nil];
NSLog(@"button data: %@", result2);
for (NSDictionary *strh in [result2 objectForKey:@"template"]) {
//the json struct above is called result2 here
//now i need to parse any category with their names..
}
関連: これは、PHP でキーと値のマッチングを使用して多次元配列を作成する方法に関する 私の質問です。