Understanding a JSON file

Before we write any code, we need to take a look at the structure of a simple JSON file. Let's create a new group inside the Misc folder in the Navigator panel called JSON. Then, we need to drag and drop all of the JSON files found in the project files for this chapter into the new JSON folder by clicking on Finish in the screen that appears. Lastly, open up the Charleston.json file and let's review the first part of it, including the first restaurant listing:

This file has four nodes inside it, total_entries, per_page, current_page, and restaurants. When you work with a feed, it will split items up into pages so that you are not trying to load all the data at once. This feed tells us that there are 67 total pages with 25 restaurants per page and that we are currently on page one. We do not need the first three nodes in this book since we are just going to load 25 restaurants.

The restaurant node, on the other hand, is essential for this book. The restaurant's node is an array of data, recognizable as such by the brackets ([ ]) used in the node. If you review the individual items in the restaurant's node, you will notice that everything needed for our app's name, address, city, and so on, is covered. This structure is the same as that which we saw in the plists earlier in this book. If you look at cuisines, you will notice that it is wrapped inside brackets ([ ]). Again, this is what we had in our plist data previously. We have an idea of what a JSON file looks like; let's see how we can work with it.