$jsonData = array('foo', 'bar'); $jsonData['catOne'] = array('foo two', 'bar two');
You don't need to. The
json_encode goes through the deepest elements and the json will be perfectly encoded:
$arr = array( 1 => array(5,6,7), 2 => array(4,3,2), ); var_dump(json_encode($arr));
The output for that is:
If you try:
The output will be:
See the difference?