gpt4 book ai didi

iphone - SBJson 解析尝试—— Objective-C

转载 作者:行者123 更新时间:2023-11-28 20:29:42 26 4
gpt4 key购买 nike

我正在尝试解析以下 JSON(我认为上次检查时已验证):

{
"top_level" = (
{
"download" = "http:/target.com/some.zip";
"other_information" = "other info";
"notes" = (
{
obj1 = "some text";
obj2 = "more notes";
obj3 = "some more text still";
}
);
title = "name_of_object1";
},
{
"download" = "http:/target.com/some.zip";
"other_information" = "other info";
"notes" = (
{
obj1 = "some text";
obj2 = "more notes";
obj3 = "some more text still";
}
);
title = "name_of_object2";
},
{
"download" = "http:/target.com/some.zip";
"other_information" = "other info";
"notes" = (
{
obj1 = "some text";
obj2 = "more notes";
obj3 = "some more text still";
}
);
title = "name_of_object3";
}
);
}

我的尝试是使用以下内容:

NSDictionary *myParsedJson = [myRawJson JSONValue];

for(id key in myParsedJson) {
NSString *value = [myParsedJson objectForKey:key];
NSLog(value);
}

错误:

-[__NSArrayM length]: unrecognized selector sent to instance 0x6bb7b40

问题:在我看来,JSon 值使 myParsedJson 对象成为 NSArray 而不是 NSDictionary。

我如何遍历名为 name_of_object 的对象并访问每个嵌套字典?我的做法是否正确?

最佳答案

NSLog 的第一个参数必须是一个字符串。试试这个:

NSLog(@"%@", value);

关于iphone - SBJson 解析尝试—— Objective-C ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12700527/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com