As we already know, Apple supports two development languages. But how is it possible to connect the JSON APIs to them?

First things first, what is JSON?

It is a lightweight data exchange format, easy to read or write for humans and it is easily analyzable or generable by machines. It is based on a subset of the JavaScript programming language (Standard ECMA-262 3rd Edition – December 1999). JSON is a text format completely independent of any language, but the conventions it uses will be familiar to any programmer accustomed to the descendant languages of C, for example: C itself, C ++, C #, Java, JavaScript, Perl, Python and many others. These properties make JSON an ideal data exchange language.

The standard format for connecting APIs to a terminal is the same one, however, on the JSON structuring model. A JSON  framework is actually a Javascript template (JavaScript Object Notation) applied to the creation of a structured data packet. There are other formats for this, such as OData, SOAP or XML, but JSON is recently the one that animates the communities.

For its part, Apple and its own iOS supports two languages: the first one is Objective-C and the second one is Swift. The good news is that you can use any framework written in these two languages and share them from one project to another. In short, you can use an old Objective-C framework in a Swift project.

Two steps are required to connect to a framework for iOS: first, identify the API that will be used, then parse the JSON.

Connect to a JSON API

Connecting to an API is the first step to actually call an API in a project from Xcode. The NSJSONSerialization class is needed here, to connect to an API. This class works for Objective-C and Swift.

How to parse JSON with frameworks for iOS

The code can be written by hand, to integrate JSON APIs into your project, or accelerate the development using one of the following frameworks:

  • JSONModel: an Objective-C framework;
  • JSONAPI-ios: an Objective-C framework;
  • ObjectMapper: a Swift framework;
  • Spine: a Swift framework;
  • SwiftyJSON: a Swift framework.

If you’re already thinking there’s a JSON framework for everything, there’s a catch. It depends on the type of project. The recommendation is to use a framework if you intend to augment an existing project in Objective-C. If you’re working on a new project, with Swift 2, you do not need to use a framework.

And after that?

Your project will be connected to an API and the data is parsed. What happens next? This is where the funny part comes. From now on, the data can be managed as you wish in an Xcode project. Mapping, connecting to business processes and/or to the thousands of public or private APIs available for iOS.