生成json是数组的形式:
string ArrayToJson()
{
using namespace rapidjson;
StringBuffer sb;
PrettyWriter<StringBuffer> writer(sb);
writer.StartArray();
writer.StartObject();
writer.String("name");
writer.String("xiaoming");
writer.EndObject();
writer.StartObject();
writer.String("name");
writer.String("xiaoming");
writer.EndObject();
writer.EndArray();
return sb.GetString();
}
运行效果如下:
[
{
"name": "xiaoming"
},
{
"name": "xiaoming"
}
]