I have a JSON object say:
Json::Value temp;
temp["example1"] = "first";
which will be represented as
{
"example1" : "first"
}
Now if I want to add another object into the above object without using the index method, how can I do it? For example:
{
"example1" : "first",
"example2" : "second"
}
but avoiding using syntax
temp["example2"] = "second";
Are there any equivalents to push_back()
(like in C++ vector/list) in JsonCpp?
The equivalent to
push_back
in JsonCpp isappend
, but you can use it only onJson::nullValue
orJson::arrayValue
.That makes sense because only one parameter is needed to add an element to an array. What are you asking is unclear/not possible, because you are trying to create an object, which is like a
std::map
in C++, and two parameters are needed to insert an element here.