gpt4 book ai didi

ios - 将带有JSON的NSString转换为NSDictionary

转载 作者:行者123 更新时间:2023-12-01 17:25:35 24 4
gpt4 key购买 nike

我有一个NSString看起来像:

{
"name": "anEvent",
"args": [
{
"ct": "Un",
"someUUID": "D7EC06DE-98D3-436F-A657-FB043567FB67",
"userName": "Joe Smith",
"long": "-139.724302",
"lat": "39.402768"
}
]
}

我怎样才能得到内在的部分
{
"ct": "Un",
"someUUID": "D7EC06DE-98D3-436F-A657-FB04383CFB67",
"userName": "Joe Smith",
"long": "-139.724305",
"lat": "39.402768"
}

变成 NSDictionary

谢谢。

最佳答案

尝试使用以下代码:

 NSDictionary *dictObj = [NSJSONSerialization JSONObjectWithData:[yourString dataUsingEncoding:NSUTF8StringEncoding]
options:NSJSONReadingMutableContainers
error:nil];
NSDictionary *requiredObject = [[dictObj objectForKey:@"args"] objectAtIndex:0];

关于ios - 将带有JSON的NSString转换为NSDictionary,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23292566/

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