Native JSON support in iOS?

2019-01-05 01:41发布

Is there a class to parse JSON from a server in the iOS SDK? (similar to NSXML for XML and by extension RSS.)

5条回答
beautiful°
2楼-- · 2019-01-05 01:49

Updated answer for iOS 5:

JSON support is now native to iOS with NSJSONSerialization, but in terms of performance, it pales in comparison to JSONKit, as John Englehart stated in the JSONKit README:

UPDATE: (2011/12/18) The benchmarks below were performed before Apples NSJSONSerialization was available (as of Mac OS X 10.7 and iOS 5). The obvious question is: Which is faster, NSJSONSerialization or JSONKit? According to this site, JSONKit is faster than NSJSONSerialization. Some quick "back of the envelope" calculations using the numbers reported, JSONKit appears to be approximately 25% to 40% faster than NSJSONSerialization, which is pretty significant.

enter image description here

Here's a blog post which delves into more specific benchmarks: JSON Libraries for iOS Comparison

查看更多
干净又极端
3楼-- · 2019-01-05 01:50

As of iOS5 JSON is been natively supported, no need for 3rd party frameworks. This is supported by the NSJSONSerialization Class!

查看更多
唯我独甜
4楼-- · 2019-01-05 02:05

NextiveJson is supposed to be quite a fast lib for iOS JSON NextiveJson

查看更多
相关推荐>>
5楼-- · 2019-01-05 02:06
我命由我不由天
6楼-- · 2019-01-05 02:06

Regarding JSONKit benchmarks, for the current moment and iOS version it's not so fast. After creating test application for testing speed NSJSONSerialization is faster but not so fast as custom implementation OKJSONParser

查看更多
登录 后发表回答