Note: the $data object in ApiView is Registry not Data object, we must use set() to set data.
Component is com_flower, view is sakuras.
// components/com_flower/view/sakuras/json.php
// ...
class FlowerViewSakurasJson extends \Windwalker\Api\View\ApiView
{
// ...
/**
* Prepare data hook.
*
* @return void
*/
protected function prepareData()
{
/** @var \Joomla\Registry\Registry $data */
$data = $this->getData();
$data->set('items', array('a', 'b', 'c'));
}
}Add this view to menu.
Type http://your_site.com/flower/sakuras.json
Then you will see this json output:
{"success":true,"message":null,"messages":[],"data":{"items":["a","b","c"]}}
Can you disable profiler on json format when JDebug in on?
{"success":true,"message":null,"messages":[],"data":[]}<hr /><pre><h3>WindWalker Debug [namespace: Windwalker]: </h3>No Profiler data.</pre>