2013/4/12 Michael Marcin
Arindam Mukherjee wrote:
In JSON we typically deal with maps and arrays. The arrays themselves could have arbitrary types (string, object, array, numeric, boolean, null) as elements. The key types in the maps are always strings and the value types in the maps could be anything that can appear in an array, including another map or array.
Due to this, I'd imagine being able to use Boost.Variant or Boost.Any in a list and as a value_type in a map would help.
Probably.
I find the most useful interface is to just provide a datatype you're expecting and let the json parser try its best to do the right thing.
Very like what I experienced with Spirit before, yeah, it just works. I let the user specify the desired types though traits specialization. The old code is here: https://github.com/jamboree/jsume/blob/master/example/pretty_printer/json_co...
For example:
string raw_json = R"({ data:{ a:"hello", b:"world", c:3, widget:3.5
} })";
This doesn't seem like a valid json, the key must be a quoted string.
struct my_type1 { map
data; }; struct my_type2 { map
> data; }; struct my_type3 { map
data; }; struct my_type4 { unordered_map
data; }; struct my_type5 { struct my_data { string a; string b; int c; float widget; } data; };
It's impossible for my_type5 without more advanced Fusion adaption.