我正在通过“JSON”从 NSMutableURLRequest
中检索数据。数据返回,我通过以下方式转换为字典:
NSDictionary* json = [NSJSONSerialization JSONObjectWithData:companyData //1
options:kNilOptions
error:&e];
我遇到的问题是,当我获取数据并返回时:
NSArray* parameterInfo = [json objectForKey:@"parameters"];
返回的数据是下面的形式,显示为 NSDictionary
但我不能为我的生活弄清楚如何将其转换为我可以读取的数据.意思是,“parameterInfo 数组”项目,我如何将其作为 NSDictionary
读取,然后能够以编程方式使用数据。
从下面可以看出,“KEY”是一个字典。
我希望这是有道理的。任何帮助是极大的赞赏。
地理位置:
2014-05-14 15:20:26.343 testdata[12052:60b] parameterInfo: {
key = {
"@name" = "Product_Search";
value = (
{
"@name" = Heated;
"@totalCount" = 2;
},
{
"@name" = Drill;
"@totalCount" = 2;
},
{
"@name" = Heat;
"@totalCount" = 1;
},
{
"@name" = Sprayer;
"@totalCount" = 1;
},
{
"@name" = Paint;
"@totalCount" = 1;
},
{
"@name" = 2653;
"@totalCount" = 2;
},
{
"@name" = "0884-20";
"@totalCount" = 1;
},
{
"@name" = Hand;
"@totalCount" = 1;
},
{
"@name" = Vacu;
"@totalCount" = 1;
},
{
"@name" = "Drill Driver";
"@totalCount" = 1;
},
{
"@name" = Blower;
"@totalCount" = 3;
},
{
"@name" = Blow;
"@totalCount" = 5;
}
);
最佳答案
忘掉整个 objectForKey
吧,它只是
NSArray *values = json[@"parameters"][@"key"][@"value];
关于ios - NSMutableURLRequest,JSON 转换为 NSDictionary,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23664708/