Am 24.03.2015 um 06:36 schrieb Laeeth Isharc:
On Tuesday, 24 March 2015 at 04:53:39 UTC, Laeeth Isharc wrote:
Hi.

struct RawGoogleResults
{
    string version_;
    string status;
    string sig;
    string[string][][string] table;
}

enum json =
"{"version":"0.6","status":"ok","sig":"717451517","table":{"cols":[{"id":"date","label":"Date","type":"date","pattern":""},{"id":"query0","label":"euro
crisis","type":"number","pattern":""}],"rows":[{"c":[{"v":"2004-01-02"),"f":"January
2004"},{"v":0.0,"f":"0"}]},{"c":[{"v":"2004-02-02"),"f":"February
2004"},{"v":0.0,"f":"0"}]},{"c":[{"v":"2004-03-02"),"f":"March
2004"},{"v":0.0,"f":"0"}]},{"c":[{"v":"2004-04-02")...

auto table = deserialize!(JsonSerializer, RawGoogleResults)(json);

I cannot pass a string to deserialize (the documentation suggests an
input range should be fine):
http://vibed.org/api/vibe.data.serialization/deserialize

I have a feeling maybe deserialize doesn't do what I want, but what
should I be using instead.  (I would like to parse the json and shove
the results in the struct above).


Thanks.


Laeeth.

Okay - figured it out from the source code.

auto results = deserialize!(JsonStringSerializer!string,
RawGoogleResults)(json);

and easier to write:

struct RawGoogleResults
{
     string version_;
     string status;
     string sig;
     //Json!array[string][][string] table;
     Json table;
}


There is http://vibed.org/api/vibe.data.json/deserializeJson for this specific case. I'll mention that in the documentation of deserialize().

Reply via email to