gpt4 book ai didi

ios - NSJSONSerialization JSONObjectWithData返回NSString

转载 作者:行者123 更新时间:2023-12-01 22:47:16 27 4
gpt4 key购买 nike

我有一个NSJSONSerialization JSONObjectWithData,我在其中传递了NSData对象。结果,我得到一个NSString而不是NSDictionary。我的完整行是:

NSDictionary* jsonDec = [NSJSONSerialization JSONObjectWithData:jData options:NSJSONReadingAllowFragments error:&error];

返回的是:

为什么我不找NSDictionary回来?我的后端是服务器上的PHP ...

提前致谢!

最佳答案

NSDictionary *jsonDec;
NSError* error = nil;
jsonDec = [NSJSONSerialization JSONObjectWithData: jData
options: NSJSONReadingMutableContainers
error: &error];

if (error)
{
NSLog(@"Error: %@",error);
}

苹果文档: NSJSONReadingMutableContainers -指定将数组和字典创建为可变对象。

关于ios - NSJSONSerialization JSONObjectWithData返回NSString,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20574376/

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