using vibe.d to parse json

Laeeth Isharc via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Mar 23 21:53:38 PDT 2015


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.


More information about the Digitalmars-d-learn mailing list