I have a following array of objects in JsonCpp::Value:
[{"foo": "bar", "baz": ["Hello", "World"]},
{"Hello": "99bottles", "baz": ["bar", "foo"]},
{"beer": "hello", "world": ["foo"]}.... ]
I have to iterate over them and alternate them (remove some elements, add another one).
I can easily iterate over JsonArray with:
for (Json::Value::ArrayIndex i = 0; i != array.size(); i++) {
doc[i] = Json::Value();
Json::Value result = array.get(i, Json::Value());
std::cout<<"-------------------"<<std::endl;
std::cout<<result.toStyledString()<<std::endl;
}
But array.get() returns a copy of object. I won't be able to modify the object itself. I can create a new array and fill it with new objects based on values from the original one but it will be very costly.
Is it possible to achieve my goal with JsonCpp "in place"? And avoid additional memory overhead?