c++11folly

How do you append objects in Folly Dynamic?


How do you append values in to the dynamic object?

If I do this :

Metrics["something"] = folly::dynamic::object("yet", 25);
Metrics["something"] = folly::dynamic::object("Notyet", 255);

I am getting

{
 "something" : {
    "Notyet" : 255
  }
}

Since I am iterating values and adding keys and values into it as I go, How Do I get

{
 "something" : {
    "Notyet" : 255,
    "yet" : 25
  }
}

I looked around, I do not see an append method, there is support for adding multiple values at the time of creation, but I need it to do it over iteration


Solution

  • More intutive than appends:

    Metrics["something"] = folly::dynamic::object;
    Metrics["something"]["yet"] = 25;
    Metrics["something"]["Notyet"] = 255;