I'm creating a JSON string exploiting boost ptree
library but I'm finding it tedious just by doing the following. I need to add a simple array like "metric.name" : [A, B]
to the metrics
ptree. Can I do better than this? Or at least write this in a cleaner way.
pt::ptree metric_avg;
metric_avg.put("", 9999);
pt::ptree metric_std;
metric_std.put("", 0);
pt::ptree metric_distr;
metric_distr.push_back({"", metric_avg});
metric_distr.push_back({"", metric_std});
metrics.add_child(metric.name, metric_distr);