I've following snippet, where I read and modify child obj attributes with at, But it doesn't get reflected in parent Obj. At the end of following code _root is written to file, But with previoius values of _child["array"].
void fun(std::vector<int> &vec) {
std::ifstream in(file);
_root = Json::parse(in);
in.close();
if (_root.find("child") != _root.end()) {
_child = _root.at("child");
_child["array"] = vec;
std::ofstream writer(file);
writer << root;
}
}
For example Previous values for _child["array"] were [1, 2] and vec contains [99, 98]. So at the end it should be 99, 98.
Previous Json values:
{
"child" : {
"array" : [1, 2]
}
}
Expected Json Values:
{
"child" : {
"array" : [99, 98]
}
}
Am I doing it right?
I've following snippet, where I read and modify child obj attributes with
at, But it doesn't get reflected in parent Obj. At the end of following code_rootis written to file, But with previoius values of_child["array"].For example Previous values for
_child["array"]were[1, 2]andveccontains[99, 98]. So at the end it should be 99, 98.Previous Json values:
Expected Json Values:
Am I doing it right?