$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] JSON Parser GSoC 2013
From: TONGARI (tongari95_at_[hidden])
Date: 2013-04-12 12:21:54
2013/4/12 Michael Marcin <mike.marcin_at_[hidden]>
> 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_config.hpp
> 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<string,string> data;
> };
>
> struct my_type2
> {
>     map<string,variant<string,int,**double>> data;
> };
>
> struct my_type3
> {
>     map<string,any> data;
> };
>
> struct my_type4
> {
>     unordered_map<string,string> 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.