Reputation: 863
I'm using boost property trees to read values from a json file.
{
"some_values":
{
"field_1": "value_1",
"field_2": true
}
}
I can read the values with:
spTree->get<string>("some_values.field_1", "");
spTree->get<bool>("some_values.field_2", false);
But can I read the type of the variable stored in any given field?
Upvotes: 4
Views: 962
Reputation: 43662
[...] the following JSON / property tree mapping is used:
[...] JSON values are mapped to nodes containing the value. However, all type information is lost; numbers, as well as the literals "null", "true" and "false" are simply mapped to their string form. Property tree nodes containing both child nodes and data cannot be mapped.
so there is no way if you intend to use the JSON parser unless you write your own code or add additional metadata.
Upvotes: 5