gpt4 book ai didi

iphone - ios5嵌套json解析

转载 作者:行者123 更新时间:2023-12-03 20:27:36 27 4
gpt4 key购买 nike

如何使用 NSJSONSerialization 转换此 json?

{
"messages":{
"message":{
"user":"value",
"pass":"value",
"url":"value"
}
}
}

最佳答案

NSError* error;
NSDictionary *dit = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:&error];
if (!error) {
//Get values from this dict using respective keys
NSDictionary *msgs = [dict objectForKey:@"messages"];
NSDictionary *msg = [msgs objectForKey:@"message"];
NSString *user = [msg objectForKey:@"user"];
NSString *pass = [msg objectForKey:@"pass"];
NSString *url = [msg objectForKey:@"url"];
}
else {
//Your error message
}

关于iphone - ios5嵌套json解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13882400/

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