如何将json字符串解析为键值对?

用户3600801

无法解析json字符串

我有以下硬编码的json。我尝试将其转换为字典并进行解析,但我无法这样做。

NSString *hcResponse  = @"{\"status\":1,\"value\":\"Successfully Login\"}";

如何将这样的json解析为键值对?

用户3600801

最后,我自己弄清楚了

//convert the string to nsdata
NSData *jsonData = [hcResponse dataUsingEncoding:NSUTF8StringEncoding];
NSError *error;
//convert the data to json dictionary
NSDictionary *jsonDic = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingAllowFragments error:nil];

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章