O'Reilly logo

Cocos2d Cross-Platform Game Development Cookbook - Second Edition by Siddharth Shekar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Loading the JSON file data

JSON, or JavaScript Object Notation, is a data format that is easy to read and a subset of JavaScript programming language. It is also quite widely used.

In this section, we will take a look at how to import a JSON file into the project.

Getting ready

To parse JSON data, we will use the touchJSON parser. You can download the project file from https://github.com/TouchCode/TouchJSON. Once downloaded, go to the Source folder and copy the files into the project. It is better to create a new group to keep the files organized.

We will parse data from the data.JSON file included in the project of this chapter. The contents of the file are as follows:

{ "nodes": [ { "type":"spriteFile", "file":"tree.png", "position":{"x":250,"y":50}, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required