来自NSString的NSJSONSerialization [英] NSJSONSerialization from NSString
本文介绍了来自NSString的NSJSONSerialization的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我有NSString并且我想使用NSJSONSerialization吗?我该怎么做?
Is it possible if I have a NSString and I want to use NSJSONSerialization? How do I do this?
推荐答案
首先你需要转换你的 NSString $ c $通过执行以下操作来c>到
NSData
First you will need to convert your NSString
to NSData
by doing the following
NSData *data = [stringData dataUsingEncoding:NSUTF8StringEncoding];
然后只需使用 JSONObjectWithData
方法进行转换它到JSON
then simply use the JSONObjectWithData
method to convert it to JSON
id json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
这篇关于来自NSString的NSJSONSerialization的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文