gpt4 book ai didi

iphone - 如何将 JSON 序列化数据转换为 NSDictionary

转载 作者:IT老高 更新时间:2023-10-28 11:30:03 26 4
gpt4 key购买 nike

我用过这个方法,

NSDictionary *jsonObject=[NSJSONSerialization 
JSONObjectWithData:jsonData
options:NSJSONReadingMutableLeaves
error:nil];
NSLog(@"jsonObject is %@",jsonObject);

它正在打印“jsonObject is null”。
“error:nil”有什么问题吗。
我没有使用任何 url 或连接方法。
我有一个 json 文件,我想在表格中显示它。

最佳答案

请尝试以下代码。

NSError* error;
NSDictionary* json = [NSJSONSerialization JSONObjectWithData:responseData
options:kNilOptions
error:&error];

NSArray* latestLoans = [json objectForKey:@"loans"];

NSLog(@"loans: %@", latestLoans);

关于iphone - 如何将 JSON 序列化数据转换为 NSDictionary,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12603047/

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