www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - std.json tree navigation help

reply "dennis" <dennisr visi.com> writes:
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.
Jan 26 2014
next sibling parent reply "cal" <callumenator gmail.com> writes:
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;
Jan 27 2014
parent "dennis" <dennisr visi.com> writes:
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.
Jan 27 2014
prev sibling parent "Dan Killebrew" <nospam gmail.com> writes:
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
Jan 27 2014