#include "json/document.h"
#include "json/writer.h"
#include "json/stringbuffer.h"
//写入资源
rapidjson::Document writedoc;
writedoc.SetObject();
rapidjson::Document::AllocatorType& allocator = writedoc.GetAllocator();
// json object 格式添加 “名称/值” 对
writedoc.AddMember("name", "neo", allocator);
writedoc.AddMember("city","nanjing", allocator);
StringBuffer buffer;
rapidjson::Writer<StringBuffer> writer(buffer);
writedoc.Accept(writer);
auto pathW = FileUtils::getInstance()->getWritablePath();
pathW.append("2.json");
FILE* file = fopen(pathW.c_str(), "wb");
if(file)
{
fputs(buffer.GetString(), file);
fclose(file);
}
CCLOG("%s",buffer.GetString());