I have read lots of answers on SO, but I cannot figure out how to make them work with my problem.
This is what I have:
{
"name": "My Company LLC ->",
"children": [
{
"name": "District of the Stores",
"children": [
{
"name": "johnny1"
},
{
"name": "jonny2"
}
]
}, //I don't want my array to end here
{
"name": "store number 10",
"children": [
{
"name": "johnny3"
},
{
"name": "jonny4"
}
]
}
]
}
This is what I want.
{
"name": "My Company LLC ->",
"children": [
{
"name": "District of the Stores",
"children": [
{
"name": "johnny1"
},
{
"name": "jonny2"
},
{
"name": "store number 10",
"children": [
{
"name": "johnny3"
},
{
"name": "jonny4"
}
]
}
]
}
]
}
Here is what I tried to do it with:
$name=array('name'=>'My Company LLC ->');
$name['children']=array(array('name'=>'District of the Stores', 'children'=>array(array('name'=>'johnny1'), array('name'=>'jonny2'))));
$name['children'][]=array('name'=>'store number 10', 'children'=>array(array('name'=>'johnny3'), array('name'=>'jonny4')));
echo '<pre>';
echo json_encode($name, JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK);
echo '</pre>';
I know that I am inserting an array at the end of the children array which is causing my second array problem in the first example, but I don't know how to put the second children array back into the first one back in the original. This is part of a big list from a database, but I'm stuck here. I cannot see where the SO answers I've found help me to insert the second array.
It looks like you want this:
$name['children'][0]['children'][] = array(...);
This would reference the first child of the root element (index 0), then proceed like you did previously by adding to that elements children array.
$name=array('name'=>'My Company LLC ->');
$name['children']=array(array('name'=>'District of the Stores', 'children'=>array(array('name'=>'johnny1'), array('name'=>'jonny2'), array('name'=>'store number 10', 'children'=>array(array('name'=>'johnny3'), array('name'=>'johnny4'))))));
echo '<pre>';
echo json_encode($name, JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK);
echo '</pre>';
Here is the output
{
"name": "My Company LLC ->",
"children": [
{
"name": "District of the Stores",
"children": [
{
"name": "johnny1"
},
{
"name": "jonny2"
},
{
"name": "store number 10",
"children": [
{
"name": "johnny3"
},
{
"name": "johnny4"
}
]
}
]
}
]
}
If you want to keep the lines of code separate you can do the following:
$name=array('name'=>'My Company LLC ->');
$name['children']=array(array('name'=>'District of the Stores', 'children'=>array(array('name'=>'johnny1'), array('name'=>'jonny2'))));
$name['children'][0]['children'][] = array('name'=>'store number 10', 'children'=>array(array('name'=>'johnny3'), array('name'=>'johnny4')));
echo '<pre>';
echo json_encode($name, JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK);
echo '</pre>';
Also, it is probably a lot easier to debug this sort of thing by looking at the array instead of encoding into json. here is your original output as an array, which really shows you what's going on better.
$name=array('name'=>'My Company LLC ->');
$name['children']=array(array('name'=>'District of the Stores', 'children'=>array(array('name'=>'johnny1'), array('name'=>'jonny2'))));
$name['children'][]=array('name'=>'store number 10', 'children'=>array(array('name'=>'johnny3'), array('name'=>'jonny4')));
echo '<pre>';
print_r($name);
echo '</pre>';
And the output is:
Array
(
[name] => My Company LLC ->
[children] => Array
(
[0] => Array
(
[name] => District of the Stores
[children] => Array
(
[0] => Array
(
[name] => johnny1
)
[1] => Array
(
[name] => jonny2
)
)
)
[1] => Array
(
[name] => store number 10
[children] => Array
(
[0] => Array
(
[name] => johnny3
)
[1] => Array
(
[name] => jonny4
)
)
)
)
)
Related
I have the following structure:
{
"data": {
"array_1": [
{
"name": "Robert Kalani"
},
{
"name": "Balkan Boy",
}
],
"array_2": [
{
"name": "Pepe Dolan"
},
{
"name": "John Nolan",
}
],
"array_3": [
{
"name": "Phillip A. Luna",
},
{
"name": "Eugene Garcia"
}
]
}
}
I would like to sort each array by the name key in alpabetical order, not sure on how to do that, I've read about array_multisort but it seemed not to work. Would greatly appreciate some help
Here is the expected output
{
"data": {
"array_1": [
{
"name": "Balkan Boy",
},
{
"name": "Robert Kalani"
}
],
"array_2": [
{
"name": "John Nolan"
},
{
"name": "Pepe Dolan"
}
],
"array_3": [
{
"name": "Eugene Garcia"
},
{
"name": "Phillip A. Luna"
}
]
}
}
// Your JSON Data
$data = '{
"data": {
"array_1": [{ "name": "Robert Kalani" }, { "name": "Balkan Boy" }],
"array_2": [{ "name": "Pepe Dolan" }, { "name": "John Nolan" }],
"array_3": [{ "name": "Phillip A. Luna" }, { "name": "Eugene Garcia" }]
}
}
';
$result = [];
// Convert your JSON data to associative array
$array = json_decode($data, true)['data'];
function sort_by_name($a, $b)
{
return $a > $b;
}
foreach ($array as $item) {
uasort($item, "sort_by_name");
$result[] = $item;
}
echo "<pre>";
print_r($result);
Result:
Array
(
[0] => Array
(
[1] => Array
(
[name] => Balkan Boy
)
[0] => Array
(
[name] => Robert Kalani
)
)
[1] => Array
(
[1] => Array
(
[name] => John Nolan
)
[0] => Array
(
[name] => Pepe Dolan
)
)
[2] => Array
(
[1] => Array
(
[name] => Eugene Garcia
)
[0] => Array
(
[name] => Phillip A. Luna
)
)
)
I would like to follow prices of stocks im interested in with a very simple php file. For this im trying to call certain data from a jsonld file, but unable to do so. Thats mostly because i cant set the correct order.
Here is my php code:
<?
// Get the contents of the JSON file
$strJsonFileContents = file_get_contents("data.jsonld");
$datas = json_decode($strJsonFileContents, True);
//var_dump($datas); // print array
$dataname = $datas->currency[ALGYO];
$dataprice = $datas->currency[ALGYO]->price;
echo $data;
?>
I've called the file, can echo with var_dump.
The Json file can be seen here
What i want to do is to call the currency ALGYO, and its price, then in another table or line call lets say ACSEL and its price and so on. I'll only call some certain elements so a list of all elements is not what im looking for. Could someone show me the way? Thanks in advance.
for those who dont want to follow pastebin link im also leavong a readiable version of json below.
{"#context": "http://schema.org",
"#type": "WebPage",
"name": "BORSA",
"mainEntity": {
"#type": "ItemList",
"name": "BORSA",
"itemListElement": [
{
"#type": "ExchangeRateSpecification",
"currency": "ALGYO",
"currentExchangeRate": {
"#type": "UnitPriceSpecification",
"price": 26.14,
"priceCurrency": "TRY"
}
},
{
"#type": "ExchangeRateSpecification",
"currency": "ARZUM",
"currentExchangeRate": {
"#type": "UnitPriceSpecification",
"price": 24.74,
"priceCurrency": "TRY"
}
},
{
"#type": "ExchangeRateSpecification",
"currency": "ACSEL",
"currentExchangeRate": {
"#type": "UnitPriceSpecification",
"price": 22.9,
"priceCurrency": "TRY"
}
},
{
"#type": "ExchangeRateSpecification",
"currency": "ADANA",
"currentExchangeRate": {
"#type": "UnitPriceSpecification",
"price": 12.19,
"priceCurrency": "TRY"
}
},
{
"#type": "ExchangeRateSpecification",
"currency": "ADBGR",
"currentExchangeRate": {
"#type": "UnitPriceSpecification",
"price": 8.62,
"priceCurrency": "TRY"
}
},
{
"#type": "ExchangeRateSpecification",
"currency": "PAMEL",
"currentExchangeRate": {
"#type": "UnitPriceSpecification",
"price": 22.02,
"priceCurrency": "TRY"
}
}
]
}
}
You could use a function, which allows you to get 'item'(stock) specific data from the json.
You can(should) tailor the function to fit your needs, here's an example that searches for an item and returns its price:
$json = file_get_contents('data.json');
$arr = json_decode($json, true);
getItem($arr, 'ALGYO'); // item : ALGYO price: 26.14
getItem($arr, 'ACSEL'); // item : ACSEL price: 22.9
function getItem($arr, $item)
{
$records = $arr['mainEntity']['itemListElement']; // the records
foreach ($records as $record) {
if ($record['currency'] == $item) {
echo 'item : ' . $item;
echo '<br />';
echo 'price : ' . $record['currentExchangeRate']['price'];
echo '<br />';
}
}
}
Although you say you don't want a list of all elements is not what im looking for, if you want to pick out specific ones in your own order it may be easier.
This just extracts the currentExchangeRate sub-array and indexes it by the currency...
$rates = array_column($datas['mainEntity']["itemListElement"],
"currentExchangeRate", "currency");
echo "ALGYO rate=" . $rates['ALGYO']['price'];
print_r($rates);
gives...
ALGYO rate=26.14
Array
(
[ALGYO] => Array
(
[#type] => UnitPriceSpecification
[price] => 26.14
[priceCurrency] => TRY
)
[ARZUM] => Array
(
[#type] => UnitPriceSpecification
[price] => 24.74
[priceCurrency] => TRY
)
[ACSEL] => Array
(
[#type] => UnitPriceSpecification
[price] => 22.9
[priceCurrency] => TRY
)
[ADANA] => Array
(
[#type] => UnitPriceSpecification
[price] => 12.19
[priceCurrency] => TRY
)
[ADBGR] => Array
(
[#type] => UnitPriceSpecification
[price] => 8.62
[priceCurrency] => TRY
)
[PAMEL] => Array
(
[#type] => UnitPriceSpecification
[price] => 22.02
[priceCurrency] => TRY
)
)
Here i have one array(first array) inside i have one more array(second array), now i want to display only first image from second array(galleryImages) , how can do this. i tried but i am not able to get the results
print_r($response);
Array
(
[0] => stdClass Object
(
[gallery_id] => 2
[title] => Annual Day 2017
[description] =>
[galleryImages] => ["1.jpg","2.jpg","3.jpg","4.jpg"]
[reg_on] => 2017-05-17 01:55:12
[created_by] => rajeshdash123#gmail.com
[school_id] => 2
[status] => 0
)
[1] => stdClass Object
(
[gallery_id] => 3
[title] => Sports Day
[description] =>
[galleryImages] => ["1.jpg","2.jpg","3.jpg"]
[reg_on] => 2017-05-17 01:55:36
[created_by] => rajeshdash123#gmail.com
[school_id] => 2
[status] => 0
)
)
Expected Results
{
"status": "Success",
"data": [
{
"gallery_id": "2",
"title": "Annual Day 2017",
"description": "",
"galleryImagesCount": 4,
"gallery":"1.jpg"
},
{
"gallery_id": "3",
"title": "Sports Day 2017",
"description": "",
"galleryImagesCount": 4,
"gallery":"1.jpg"
}
],
}
I tried like this but is i am not getting the exact results
$images = array();
foreach ($response as $key => $value)
{
$img['gallery_id'] = $value->gallery_id;
$img['title'] = $value->title;
$img['description'] = $value->description;
$img['galleryImagesCount'] = count(json_decode($value->galleryImages,true));
$img['gallery'] = json_decode($value->galleryImages,true);
array_push($images,$img);
}
$return=array('status'=>"Success",'Images'=>$images);
echo json_encode($return);
Getting Results
{
"status": "Success",
"Images": [
{
"gallery_id": "2",
"title": "Annual Day 2017",
"description": "",
"galleryImagesCount": 4,
"gallery": [
"d17ac9d0aeb6435eaa294e0d69d4cc8f.jpg",
"a91945e0cf55379f51cf5faef10d7a4a.jpg",
"2d1501045ddbb3ccc238e70f9af05027.jpg",
"071c3b5f969bed1d1e2ee4b6531e4444.jpg"
]
},
{
"gallery_id": "3",
"title": "Sports Day",
"description": "",
"galleryImagesCount": 4,
"gallery": [
"f0ba574fd46a01ff5a41855a97c710ca.jpg",
"1d10802f1b74e660117f36bd6dd0aa26.jpg",
"e705fb66f767a1b914200ca8d3cae700.jpg",
"3d5d8828331e13d3decc94021a64e5ca.jpg"
]
}
]
}
Here what happening means gallery is coming an array , for me don't want array i need first image only, please check my expected results, update the answer
Updated expected results
{
"status": "Success",
"Images": [
{
"gallery_id": "2",
"title": "Annual Day 2017",
"description": "",
"galleryImagesCount": 4,
"gallery": [
{
"galleryimage": "1.jpg"
},
{
"galleryimage": "2.jpg"
}
]
},
{
"gallery_id": "3",
"title": "Sports Day",
"description": "",
"galleryImagesCount": 4,
"gallery": [
{
"galleryimage": "1.jpg"
},
{
"galleryimage": "2.jpg"
}
]
}
]
}
Instead of [galleryImages] => ["1.jpg","2.jpg","3.jpg"], use for loop to iterate through galleryImages.
Create an associative array with key =>value pair like [galleryImages] => ["galleryimage1" => "1.jpg", "galleryimage2" => "2.jpg", "galleryimage3" => "3.jpg"].
While json_decode you will get intended output.
My changes and explanations are in the code block:
Code: (Demo)
// assumed that previous line was something like $response=json_decode($json);
$response=[
(object)[
'gallery_id'=>2,
'title'=>'Annual Day 2017',
'description'=>'',
'galleryImages'=>["1.jpg","2.jpg","3.jpg","4.jpg"],
'reg_on'=>'2017-05-17 01:55:12',
'created_by'=>'rajeshdash123#gmail.com',
'school_id'=>2,
'status'=>0
],
(object)[
'gallery_id'=>3,
'title'=>'Sports Day',
'description'=>'',
'galleryImages'=>["1.jpg","2.jpg","3.jpg"],
'reg_on'=>'2017-05-17 01:55:36',
'created_by'=>'rajeshdash123#gmail.com',
'school_id'=>2,
'status'=>0
]
];
foreach ($response as $value){ // removed $key=> because it was unnecessary
$img['gallery_id'] = $value->gallery_id;
$img['title'] = $value->title;
$img['description'] = $value->description;
$img['galleryImagesCount'] = count($value->galleryImages); // removed json_decode()
$img['gallery'] = $value->galleryImages[0]; // removed json_decode and added [0] to access first
$images[]=$img; // swapped push() call with identical function-less "push"
}
if(isset($images)){ // added this condition to ensure there was something to return
$return=array('status'=>"Success",'Images'=>$images);
//var_export($return);
echo json_encode($return);
}else{
// enter some sort of error message / default behavior
}
Output:
{"status":"Success","Images":[{"gallery_id":2,"title":"Annual Day 2017","description":"","galleryImagesCount":4,"gallery":"1.jpg"},{"gallery_id":3,"title":"Sports Day","description":"","galleryImagesCount":3,"gallery":"1.jpg"}]}
I have a result from my MySQL DB that I'm json encoding in PHP, the result looks like
:
[
{
"id": "8488",
"name": "Tenby",
"area": "Area1"
},
{
"id": "8489",
"name": "Harbour",
"area": "Area1"
},
{
"id": "8490",
"name": "Mobius",
"area": "Area1"
}
]
What I would like to do is to add a new key/value pair to that JSON so that it will be :
[
{
"id": "8488",
"name": "Tenby",
"area": "Area1",
"image": "1278.jpg"
},
{
"id": "8489",
"name": "Harbour",
"area": "Area1",
"image": "1279.jpg"
},
{
"id": "8490",
"name": "Mobius",
"area": "Area1",
"image": "1280.jpg"
}
]
So how can I do that in PHP?
<?php
$data[0]['id']="8488";
$data[0]['name']="Tenby";
$data[0]['area']="Area1";
$data[1]['id']="8489";
$data[1]['name']="Harbour";
$data[1]['area']="Area1";
$data[2]['id']="8490";
$data[2]['name']="Mobius";
$data[2]['area']="Area1";
echo json_encode($data)."<br/>";
/*Add Image element (or whatever) into the array according to your needs*/
$data[0]['image']="1278.jpg";
$data[1]['image']="1279.jpg";
$data[2]['image']="1280.jpg";
echo json_encode($data);
?>
PHP is not very good with JSON. Its best to convert from JSON to Array to do this - what #egig has also recommended.
Example code:
$temp = json_decode($json);
$temp[] = new data, whatever you want to add...;
$json = json_encode($temp);
Hope this helps.
hu?
the result of the db query will be an array or an object...
add the additional entry to that data, only encode after every necessary data manipulation is done
alternatives, but clumsy (horrible):
json_decode, add stuff, json_encode
build your additional data as a string, str_replace for example "area": "Area1" in your json string with "area": "Area1", "image": "1278.jpg"
but really:
output formatting like json_encode should only be done once you are sure that you have the whole output together and it is send out
Maybe things have changed since then, but I know this will work at this current stage:-
So here is the JSON string:-
$strJSON = '[
{
"id": "8488",
"name": "Tenby",
"area": "Area1"
},
{
"id": "8489",
"name": "Harbour",
"area": "Area1"
},
{
"id": "8490",
"name": "Mobius",
"area": "Area1"
}
]';
If this is still a string, then I would convert it into an object like this:-
$json = json_decode( $strJSON );
Now that it is in object format, to add my "image" keys with their values, I would then add them like it is shown below:-
$json[0]->image = "1278.jpg";
$json[1]->image = "1279.jpg";
$json[2]->image = "1280.jpg";
So then if I add the code below after the above code:-
echo "<pre>";
print_r( $json );
echo "</pre>";
We should then see it outputting on the page like so:-
Array
(
[0] => stdClass Object
(
[id] => 8488
[name] => Tenby
[area] => Area1
[image] => 1278.jpg
)
[1] => stdClass Object
(
[id] => 8489
[name] => Harbour
[area] => Area1
[image] => 1279.jpg
)
[2] => stdClass Object
(
[id] => 8490
[name] => Mobius
[area] => Area1
[image] => 1280.jpg
)
)
//$index = some value in array;
for($i=0;$i<count($index);$i++){
$data[$i]->key = $index[$i];
}
print $data;
I want to tranform an php array into an json string to use with JavaScript InfoVis Toolkit formart.
the objective:
InfoVis Demo Tree
Json specification format:
InfoVis-loading and serving JSON data
I have this php array: $my_array :
Array
(
[item_1] => Array
(
[id] => item_1_ID
[name] => item_1_NAME
[data] => item_1_DATA
[children] => Array
(
[door] => Array
(
[id] => door_ID
[name] => door_NAME
[data] => door_DATA
[children] => Array
(
[mozart] => Array
(
[id] => mozart_ID
[name] => mozart_NAME
[data] => mozart_DATA
[children] => Array
(
[grass] => Array
(
[id] => grass_ID
[name] => grass_NAME
[data] => yes
)
[green] => Array
(
[id] => green_ID
[name] => green_NAME
[data] => no
)
[human] => Array
(
[id] => human_ID
[name] => human_NAME
[data] => human_DATA
[children] => Array
(
[blue] => Array
(
[id] => blue_ID
[name] => blue_NAME
[data] => blue_DATA
[children] => Array
(
[movie] => Array
(
[id] => movie_ID
[name] => movie_NAME
[data] => yes
)
)
)
)
)
)
)
)
)
[beat] => Array
(
[id] => beat_ID
[name] => beat_NAME
[data] => yes
)
[music] => Array
(
[id] => music_ID
[name] => music_NAME
[data] => no
)
)
)
)
now if I json_encode($my_array);
{
"item_1": {
"id": "item_1_ID",
"name": "item_1_NAME",
"data": "item_1_DATA",
"children": {
"door": {
"id": "door_ID",
"name": "door_NAME",
"data": "door_DATA",
"children": {
"mozart": {
"id": "mozart_ID",
"name": "mozart_NAME",
"data": "mozart_DATA",
"children": {
"grass": {
"id": "grass_ID",
"name": "grass_NAME",
"data": "yes"
},
"green": {
"id": "green_ID",
"name": "green_NAME",
"data": "no"
},
"human": {
"id": "human_ID",
"name": "human_NAME",
"data": "human_DATA",
"children": {
"blue": {
"id": "blue_ID",
"name": "blue_NAME",
"data": "blue_DATA",
"children": {
"movie": {
"id": "movie_ID",
"name": "movie_NAME",
"data": "yes"
}
}
}
}
}
}
}
}
},
"beat": {
"id": "beat_ID",
"name": "beat_NAME",
"data": "yes"
},
"music": {
"id": "music_ID",
"name": "music_NAME",
"data": "no"
}
}
}
}
But to InfoVis the current json output (json_encode($my_array)) has 3 problems:
is not using [ ]
the 'children' arrays have the key names
arrays items is with their key names -> example: "item_1": { ....
let me point the problem so maybe you can help with an function to transform this json string:
see this slice of json_encode($my_array) output:
{
"item_1": {
"id": "item_1_ID",
"name": "item_1_NAME",
"data": "item_1_DATA",
"children": {
"door": {
"id": "door_ID",
1. problem 1:
{
"item_1": {
we have to remove those keys like: "item_1":
2. problem 2:
"children": {
"door": {
"id": "door_ID",
the correct code for this should be:
"children": [
{
"id": "door_ID",......
"door": was removed... because it`s a key
"children": { => becomes" "children": [
An working example of 'children':
"children": [
{
"id": "grass_ID",
"name": "grass_NAME",
"data": "yes"
},
{
"id": "green_ID",
"name": "green_NAME",
"data": "no"
}
]
to clarify an complete example of WORKING Json InfoVis format:
json = {
id: "node02",
name: "0.2",
children: [{
id: "node13",
name: "1.3",
children: [{
id: "node24",
name: "2.4"
}, {
id: "node222",
name: "2.22"
}]
}, {
id: "node125",
name: "1.25",
children: [{
id: "node226",
name: "2.26"
}, {
id: "node237",
name: "2.37"
}, {
id: "node258",
name: "2.58"
}]
}, {
id: "node165",
name: "1.65",
children: [{
id: "node266",
name: "2.66"
}, {
id: "node283",
name: "2.83"
}, {
id: "node2104",
name: "2.104"
}, {
id: "node2109",
name: "2.109"
}, {
id: "node2125",
name: "2.125"
}]
}, {
id: "node1130",
name: "1.130",
children: [{
id: "node2131",
name: "2.131"
}, {
id: "node2138",
name: "2.138"
}]
}]
};
is it clear to understand?
Hope anyone can help me.. I'm working on this for days!
thank you.
Try this quickie conversion function
function fixit($yourArray) {
$myArray = array();
foreach ($yourArray as $itemKey => $itemObj) {
$item = array();
foreach ($itemObj as $key => $value) {
if (strtolower($key) == 'children') {
$item[$key] = fixit($value);
} else {
$item[$key] = $value;
}
}
$myArray[] = $item;
}
return $myArray;
}
$fixed = fixit($my_array);
$json = json_encode($fixed);
PHP doesn't differentiate between arrays (numeric keys) and associative arrays (string keys). They're all just Arrays. Javascript DOES differentiate. Since you're using string keys, they HAVE to be done as objects ({}) in JS.
You can't tell json_encode to ignore the keys in an array (e.g. your 'children' sub-arrays). That'd mean the produced JSON is NOT the same as the original PHP structure - you've now changed key names.
You'd have to process your array and convert all those children sub-array keys to numbers:
grass -> 0
green -> 1
etc...
so that json-encode could see that it's a numerically keyed PHP array, meaning it'll produce an actual javavscript array ([]), and not an object ({}).
The alternative is writing your own JSON-encoder to do this on-the-fly for you.
This is documented behaviour. An associative array will produce an object literal when JSON stringified with json_encode. Update your original array structure to represent the outcome you want, instead of mangling the produced JSON representation, or wrap your own solution around json_encode for each object.
Edit: attempting a cleanup operation
The code
$original = <your original data-array>; // assumed, I reversed your encoded JSON as test data
// Start by stripping out the associative keys for level 1
$clean = array_values($original);
// Then recursively descend array, and do the same for every children-property encountered
function &recursiveChildKeysCleaner(&$arr) {
// If $arr contains 'children'...
if (array_key_exists('children', $arr)) {
/// ...strip out associative keys
$arr['children'] = array_values($arr['children']);
// ...and descend each child
foreach ($arr['children'] as &$child) {
recursiveChildKeysCleaner($child);
}
}
return $arr;
}
foreach ($clean as &$item) {
recursiveChildKeysCleaner($item);
}
unset($item);
echo json_encode($clean);
Output
[{
"id": "item_1_ID",
"name": "item_1_NAME",
"data": "item_1_DATA",
"children": [{
"id": "door_ID",
"name": "door_NAME",
"data": "door_DATA",
"children": [{
"id": "mozart_ID",
"name": "mozart_NAME",
"data": "mozart_DATA",
"children": [{
"id": "grass_ID",
"name": "grass_NAME",
"data": "yes"
},
{
"id": "green_ID",
"name": "green_NAME",
"data": "no"
},
{
"id": "human_ID",
"name": "human_NAME",
"data": "human_DATA",
"children": [{
"id": "blue_ID",
"name": "blue_NAME",
"data": "blue_DATA",
"children": [{
"id": "movie_ID",
"name": "movie_NAME",
"data": "yes"
}]
}]
}]
}]
},
{
"id": "beat_ID",
"name": "beat_NAME",
"data": "yes"
},
{
"id": "music_ID",
"name": "music_NAME",
"data": "no"
}]
}]