Parseing single JSON value from webpage
Vladimir Panteleev via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Apr 28 19:38:06 PDT 2015
On Wednesday, 29 April 2015 at 02:34:20 UTC, William Dunne wrote:
> Sorry for the noob question.
>
> I'm currently trying to parse this bit of json:
>
> Array
> (
> [meta] => Array
> (
> [level1trust] => 1
> [level2trust] => 9
> )
>
> [connections] => Array
> (
> [level1] => Array
> (
> [from] => name
>
> )
> ///lots more json.
>
> This seems like it could be done with std.json, however I'm
> struggling to understand how using my json object, I can get
> the value for level1trust
>
> Anyone willing to lend a hand?
auto json = `{"meta" : {"level1trust" : 1, "level2trust" : 9}}`;
auto parsed = parseJSON(json);
assert(parsed["meta"]["level1trust"].integer == 1);
BTW, you probably know that, but your output is not JSON - it
looks like a PHP dump.
More information about the Digitalmars-d-learn
mailing list