问题描述
如何在c ++中的一个对象中存储多个json对象
例如
json :: value obj1;
obj1 [ID ] =12
obj1 [姓名] =abc
json :: value obj2;
obj2 [ID] =11
obj2 [姓名] =xyz
我想要将上述两个对象存储在一个json对象中
json :: value obj3;
outupt如下格式
obj3 = [{ID:12,名称:abc},{ID:11,名称:xyz}]
我的尝试:
json :: value obj1;
obj1 [ID] =12
obj1 [姓名] =abc
json :: value obj2 ;
obj2 [ID] =11
obj2 [姓名] =xyz
items [0] = item;
group [LItems] = items;
utility :: stringstream_t stream;
group.serialize(stream);
json :: value obj3;
obj3 [0] = item;
group [LItems] = items;
实用程序: :stringstream_t stream;
group.serialize(stream);
how to store multiple json object in one object in c++
For example
json::value obj1;
obj1["ID"]="12"
obj1["Name"]="abc"
json::value obj2;
obj2["ID"]="11"
obj2["Name"]="xyz"
I want to store the above two objects in one json object
json::value obj3;
outupt is like in below format
obj3=[{"ID":"12","Name":"abc"},{"ID":"11","Name":"xyz"}]
What I have tried:
json::value obj1;
obj1["ID"]="12"
obj1["Name"]="abc"
json::value obj2;
obj2["ID"]="11"
obj2["Name"]="xyz"
items[0] = item;
group[L"Items"] = items;
utility::stringstream_t stream;
group.serialize(stream);
json::value obj3;
obj3[0] = item;
group[L"Items"] = items;
utility::stringstream_t stream;
group.serialize(stream);
这篇关于如何在C ++中的一个对象中存储多个json对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!