Cocos2d-X 3.0 中自带了rapidjson,用于解析Json。
可以直接拿过来使用,只要引入头文件
#include "json/document.h"
char json[100] = "{"hello": "world"}";
rapidjson::Document d1;
d1.Parse<0>(json);
log("json1: %s", d1["hello"].GetString());
//2.从文件读取
std::string filePath = FileUtils::getInstance()->fullPathForFilename("jsonTest.json");
std::string contentStr = FileUtils::getInstance()->getStringFromFile(filePath);
rapidjson::Document d2;
d2.Parse<0>(contentStr.c_str());
log("json2: %d", d2["i"].GetInt());
Demo: http://download.csdn.net/detail/liangshaoze/7071529
