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