Thread overview
std.json tree navigation help
Jan 27, 2014
dennis
Jan 27, 2014
cal
Jan 28, 2014
dennis
Jan 28, 2014
Dan Killebrew
January 27, 2014
I am having trouble understanding how to navigate the tree returned by std.json.  I am new to D programming, I have tried reading the std.json source code but I am still stumped.

I want to iterate the tree of JSONValue(s) by the json objects key names and I need to be test the type of the value pointed to by the key name so that I can descend into arrays or other objects as needed.  Basically I want search the JSONValue tree but I am stumped on how to do this.  Any examples or hints would be appreciated.
January 27, 2014
On Monday, 27 January 2014 at 06:51:57 UTC, dennis wrote:
> I am having trouble understanding how to navigate the tree returned by std.json.  I am new to D programming, I have tried reading the std.json source code but I am still stumped.

I usually end up doing something like this when dealing with std.json:

http://dpaste.dzfl.pl/bcb14d6a;
January 28, 2014
On Monday, 27 January 2014 at 23:26:44 UTC, cal wrote:
> I usually end up doing something like this when dealing with std.json:
>
> http://dpaste.dzfl.pl/bcb14d6a;

Cool, thank you.

Your example really helps clear this up for me.  Plus I liked the use of the popBackN() method call on the string, I would not have know how to use that method in that way either.

Your example also crystallized what the opIndex ref's in the JSONValue documentation meant.


January 28, 2014
Check out the json module in vibe.d. Maybe copy it into your own application (since it can't be used as a library, yet).
http://vibed.org/api/vibe.data.json/
https://github.com/rejectedsoftware/vibe.d