Parse json file in cocos2dx
I am working on cocos2d-x project, I will be using my iOS and Android code. Now I am using a json file to store unlock data, but I don't know how to parse the data in cocos2dx. can i get a quick guide (demo code) so i can continue my project.
I created a json file and saved the data in it. I put the demo inside a json file.
{
"id": "food",
"name": "cherry",
"price": "20 coins",
"unlock": {
"level": 15,
"advance_unlock_price": "200 coins"
}
}
+3
bbm20891
source
to share
2 answers
You can use quickjson which is part of Cocos2d-x.
Using Rapidjson in Cocos2D-X: Generating a JSON Document in Code and Batch Production
+4
Kazuki sakamoto
source
to share
Use fast json if your game is large scale otherwise you can use jsonccp it is lightweight but not good compared to quickjson.rapidjson faster than any parser.
fast json:
http://rapidjson.org/
jsoncpp: https://github.com/open-source-parsers/jsoncpp
+2
Shauket sheikh
source
to share