rapidjson建立json

Document document_;

Document::AllocatorType&   allocator = document_.GetAllocator();


1.Value val;定义

val.SetObject();

Value ary;

ary.SetArray();

2.Value val(kObjectType);

Value ary(kArrayType);


3.val.AddMember("key name" , value , allocator);

4.ary.PushBack(1,allocator);

ary.PushBack(2,allocator);

ary.PushBack(3,allocator);

ary.PushBack(4,allocator);

 

5.val.AddMember("key name" , ary , allocator);

6.

StringBuffer buffer;

Writer<StringBuffer> writer(buffer);

val.Accept(writer);

std::string output = buffer.GetString();

NOTICE("%s" , output.c_str());


猜你喜欢

转载自blog.csdn.net/hhgfg1980/article/details/53313847