Below is a sample of final json I pass to javascript. I will use the (yajl) ruby library to create this json from a hash.
The question is what should a ruby hash that produces the json below look like?
var data = [{
data: "basics",
attr: {},
children: [
{data: "login", attr: {run: "run"},
children: [
{data: "login", attr: {}}
]
} ,
{data: "Academic Year", attr: {run: "run"},
children: [
{data: "login", attr: {}},
{data: "Academic Year", attr: {filter: "mini", SOF: "yes"}}
]
}
]
}];
Your question is not too clear. Do you mean what is the Ruby structure that would create the JSON you show in your question?
If so, then here you go.... Note that the base-level structure is a Ruby Array because your JSON base level structure is also an Array.
mydata = [{
'data' => "basics",
'attr' => {},
'children' => [{
'data' => "login",
'attr' => {'run' => "run"},
'children' => [{
'data' => "login",
'attr' => {}
}]
},
{
'data' => "Academic Year",
'attr' => {'run' => "run"},
'children' => [{
'data' => "login",
'attr' => {}
},
{
'data' => "Academic Year",
'attr' => {'filter' => "mini",
'SOF' => "yes"}
}]
}]
}]