Fastest JSON parser in the world is a D project
wobbles via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Tue Oct 27 06:14:34 PDT 2015
On Monday, 26 October 2015 at 20:04:33 UTC, Nordlöw wrote:
> On Wednesday, 14 October 2015 at 07:35:49 UTC, Marco Leise
> wrote:
>> Example:
>>
>> double x = 0, y = 0, z = 0;
>> auto json = parseTrustedJSON(`{ "coordinates": [ { "x": 1,
>> "y": 2, "z": 3 }, … ] }`);
>>
>> foreach (idx; json.coordinates)
>> {
>> // Provide one function for each key you are
>> interested in
>> json.keySwitch!("x", "y", "z")(
>> { x += json.read!double; },
>> { y += json.read!double; },
>> { z += json.read!double; }
>> );
>> }
>
> How can `coordinates` member be known at compile-time when the
> input argument is a run-time string?
I suspect through the opDispatch operator overload.
http://dlang.org/operatoroverloading.html#dispatch
More information about the Digitalmars-d-announce
mailing list