std.data.json formal review

Piotr Szturmaj via Digitalmars-d digitalmars-d at puremagic.com
Wed Jul 29 18:17:54 PDT 2015


W dniu 2015-07-29 o 00:37, H. S. Teoh via Digitalmars-d pisze:
> On Tue, Jul 28, 2015 at 03:29:02PM -0700, Walter Bright via Digitalmars-d wrote:
> [...]
>> 3. Stepping back a bit, when I think of parsing JSON data, I think:
>>
>>      auto ast = inputrange.toJSON();
>>
>> where toJSON() accepts an input range and produces a container, the
>> ast. The ast is just a JSON value. Then, I can just query the ast to
>> see what kind of value it is (using overloading), and walk it as
>> necessary.
>
> +1. The API should be as simple as possible.
>
> Ideally, I'd say hook it up to std.conv.to for maximum flexibility. Then
> you can just use to() to convert between a JSON container and the value
> that it represents (assuming the types are compatible).
>
> OTOH, some people might want the option of parser-driven data processing
> instead (e.g. the JSON data is very large and we don't want to store the
> whole thing in memory at once). I'm not sure what a good API for that
> would be, though.

Here's mine range based parser, you can parse 1 TB json file without a 
single allocation. It needs heavy polishing, but I didnt have time/need 
to do it. Basically a WIP, but maybe someone will find it useful.

https://github.com/pszturmaj/json-streaming-parser


More information about the Digitalmars-d mailing list