你如何在 Folly Dynamic 中附加对象?
How do you append objects in Folly Dynamic?
如何将值附加到动态对象?
如果我这样做:
Metrics["something"] = folly::dynamic::object("yet", 25);
Metrics["something"] = folly::dynamic::object("Notyet", 255);
我收到了
{
"something" : {
"Notyet" : 255
}
}
由于我正在迭代值并在其中添加键和值,我如何获得
{
"something" : {
"Notyet" : 255,
"yet" : 25
}
}
我环顾四周,没有看到 append 方法,支持在创建时添加多个值,但我需要它在迭代中完成
比追加更直观:
Metrics["something"] = folly::dynamic::object;
Metrics["something"]["yet"] = 25;
Metrics["something"]["Notyet"] = 255;
如何将值附加到动态对象?
如果我这样做:
Metrics["something"] = folly::dynamic::object("yet", 25);
Metrics["something"] = folly::dynamic::object("Notyet", 255);
我收到了
{
"something" : {
"Notyet" : 255
}
}
由于我正在迭代值并在其中添加键和值,我如何获得
{
"something" : {
"Notyet" : 255,
"yet" : 25
}
}
我环顾四周,没有看到 append 方法,支持在创建时添加多个值,但我需要它在迭代中完成
比追加更直观:
Metrics["something"] = folly::dynamic::object;
Metrics["something"]["yet"] = 25;
Metrics["something"]["Notyet"] = 255;