解析NSJSONReadingAllowFragments

解析NSJSONReadingAllowFragments,第1张

解析NSJSONReadingAllowFragments

看来您的服务器发送了“嵌套JSON”:

jsonResponse
是JSON 字符串 (不是 dictionary
)。该字符串的值再次是表示字典的JSON数据。

在这种情况下,您必须两次反序列化JSON:

NSString *jsonString = [NSJSonSerialization JSONObjectWithdata:jsonResponse options:NSJSonReadingAllowFragments error:nil];NSData *innerJson = [jsonString dataUsingEncoding:NSUTF8StringEncoding];NSDictionary *jsonDict = [NSJSonSerialization JSONObjectWithdata:innerJson options:0 error:nil];NSString *email = jsonDict[@"email"];


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/4909952.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-12
下一篇 2022-11-12

发表评论

登录后才能评论

评论列表(0条)

保存