Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Native JSON support in iOS?

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

like image 845
Moshe Avatar asked Aug 25 '10 02:08

Moshe


People also ask

Does JSON work with iOS?

JSON is a popular data-interchange format used by APIs (application programming interfaces). JSON lets you bundle a large amount of data into one chunk of text and then send it along to another service.

What is JSON serialization in iOS?

An object that converts between JSON and the equivalent Foundation objects.

What is iOS JSON?

JSON (JavaScript Object Notation) is a lightweight format, which is widely used to send data over the internet. The JSON format includes dictionaries and arrays. In this tutorial some data is requested from a web server and displayed on screen. This tutorial is made with Xcode 10 and built for iOS 12.

Which JSON framework is used for Swift?

You can use the Foundation framework's JSONSerialization class to convert JSON into Swift data types like Dictionary, Array, String, Number, and Bool.


2 Answers

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

like image 124
Edwin Avatar answered Oct 04 '22 11:10

Edwin


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

like image 31
Jacob Relkin Avatar answered Oct 04 '22 11:10

Jacob Relkin