bbm20891
bbm20891

Reputation: 144

Parse json file in cocos2dx

i am working on cocos2d-x project i will use my code for ios and android both. Now i am using json file to store unlock data but i don't know how to parse the data in cocos2dx. can i have brief tutorial (demo code) so that i can proceed with my project.

i have created json file and save data in it. i put demo of inside json file.

{
  "id": "food",
  "name": "cherry",
  "price": "20 coins",
  "unlock": {
    "level": 15,
    "advance_unlock_price": "200 coins"
  }
}

Upvotes: 3

Views: 6857

Answers (2)

Muhammad Shauket
Muhammad Shauket

Reputation: 2778

Use rapid json if your game has big big scale otherwise you can use jsonccp it is lightweight but not good as compared to rapidjson.rapidjson more fast than any parser.

rapid json:

http://rapidjson.org/

jsoncpp: https://github.com/open-source-parsers/jsoncpp

Upvotes: 2

Kazuki Sakamoto
Kazuki Sakamoto

Reputation: 13999

You can use rapidjson that is a part of Cocos2d-x.

Using Rapidjson in Cocos2D-X: Creating a JSON Document in Code and Serializing it

Upvotes: 4

Related Questions