NSJSONSerialization from NSString

后端 未结 4 648
眼角桃花
眼角桃花 2020-12-03 00:41

Is it possible if I have a NSString and I want to use NSJSONSerialization? How do I do this?

4条回答
  •  一个人的身影
    2020-12-03 01:10

    I wrote a blog post that demonstrates how to wrap the native iOS JSON class in a general protocol together with an implementation that use the native iOS JSON class.

    This approach makes it a lot easier to use the native functionality and reduces the amount of code you have to write. Furthermore, it makes it a lot easier to switch out the native implementation with, say, JSONKit, if the native one would prove to be insufficient.

    http://danielsaidi.com/blog/2012/07/04/json-in-ios

    The blog post contains all the code you need. Just copy / paste :)

    Hope it helps!

提交回复
热议问题