Goal: Use json_encode to format array data into a specified format
This is the needed format for the data after running through PHP json_encode:
NEEDED FORMAT
{
"top_level_data": [
{
"extension": {},
"sub_level_data1": 0
}
]
}
When I use this PHP:
$data = array('top_level_data' => array('extension' => array(),
'sub_level_data1' => 0
)
)
$data = json_encode($data);
I get this incorrect Output:
{
"top_level_data":{
"extension":[],
"sub_level_data1": 0
}
}
Question: How can I modify my php to include the {} and the [] in the correct places as the Needed Format?