登录
  • 欢迎访问 Sharezer Blog

cocos2d-x 3.0 rapidjson 读取Json

Cocos sharezer 1951次浏览 已收录 0个评论

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());

cocos2d-x 3.0 rapidjson 读取Json

Demo: http://download.csdn.net/detail/liangshaoze/7071529


Sharezer , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明cocos2d-x 3.0 rapidjson 读取Json
喜欢 (1)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址