I have been looking for APIs in boost::property_tree (that is used for reading a json) that I can use to determine if a value of a field is a tree or a terminal value. For example, I have a json where the value of foo can either be a tree as illustrated in the first block or a string as illustrated in the second block.
{
"foo": {
" n1": "v1",
"n2": "v2"
}
}
{
"foo": "bar"
}
I know we can check first with get_child_optional. If the returned value is null, then we can check get_optional. But are there any better ways/apis to do this?
pt.data().empty()
instead ofpt.data.empty()
. – Microcopy