Hi,
Could you please share how to get the nested json using ItemFileReadStore or ItemFileWriteStore?
Following code works only if I remove the children from the json.
myJson.json:
{ identifier: "id",
items: [
{"name":"name1",
"id":1,
"children":[{"name": "child1","childId":1},
{"name": "child2","childId":2}]
},
...........etc
]
}
code to fetch the above json:
function fetchJson(){
var store = new dojo.data.ItemFileReadStore({url:'myJson.json'});
store.fetch({
onComplete: function(items) {
alert(items[i]).name; // I had some other code, but this line was just for a test
}});}
Can someone please let me know how to load the entire nested json?? I have spent a lot of time going through multiple posts and tried multiple things, so please suggest something that really works. I would really appreciate your help.
thanks
Rakesh

Items from the store aren't
Items from the store aren't returned as objects you can reference using dot notation (e.g. items[i].name). Because stores are assumed to be asynchronous, you have to get the values via the store itself using getValue or getValues.
Also, if you want to have children, you have to use the _reference property in your data (and probably have a way to differentiate parents and children in your data, like with a 'type' property).
For example:
var data = { 'identifier': 'name',
'label': 'name',
'items': [
{ 'name':'Dad', 'type':'parent', age: 30,
'children':[{'_reference':'Bobby'}, {'_reference':'Jane'}, {'_reference':'Brat'}] },
{ 'name':'Brat', 'type':'child', age: 5 },
{ 'name':'Jane', 'type':'child', age: 4 },
{ 'name':'Bobby', 'type':'child', age: 2 }
]};
dojo.addOnLoad( function( ) {
var store = new dojo.data.ItemFileReadStore( { data: data } );
store.fetch( { query: { type: 'parent' },
onComplete: function( items ) {
dojo.forEach( items, function( item ) {
console.log( 'parent: ', store.getValue( item, "name" ), ' age: ', store.getValue( item, 'age') );
var children = store.getValues( item, "children");
dojo.forEach( children, function(child) {
console.log( ' -- child: ', store.getValue( child, "name" ), ' age: ', store.getValue( child, 'age') );
});
});
},
onError: function(e) {
console.error( "!!!!",arguments );
}
});
});
You can see it in action here:
http://jsbin.com/ebixe
You'll need to have firebug installed and enabled for jsbin.com.
A good place to start with the data stores is the tests in dojo/tests/data. Most of the code above is taken from that actually.
Let me know if you have any more questions.
HTH.