Array
(
[sEcho] => 0
[iTotalRecords] => 2
[iTotalDisplayRecords] => 2
[aaData] => Array
(
[0] => Array
(
[0] => value1
[1] => value2
[2] => value3
[3] => value4
)
[1] => Array
(
[0] => value1
[1] => value2
[2] => value3
[3] => value4
)
)
)
{"sEcho":0,"iTotalRecords":"2","iTotalDisplayRecords":"2","aaData":}
This question has been answered by shamblett. See the first response.
<?php
$output = '';
$ar = array(
'foo' => 'bar',
'fuu' => 'bur',
'nested' => array(
array(1,2,3),
array(4,5,6)
)
);
$par = print_r($ar, true);
$output .= 'print_r($ar): <br/><pre>'.$par.'</pre><br/>';
$output .= "toJSON: ".$modx->toJSON($ar).'<br/>';
$output .= 'json_encode: '.json_encode($ar).'<br/>';
return $output;
I think your falling foul of Revo stripping tags, your nested array should start with '[' or even '[[', these are stripped by Revo when the page is delivered. I fell foul of this, have a look here : https://forums.modx.com/thread/79688/json-encode-problem#dis-post-438886
No probs, personally I think a resource with a content type of JSON shouldn't be parsed, i.e. the content as generated by the snippet should just be returned untouched, this would allow AJAX calls to just work and take out any delay involved with parsing the output.