I have a JSON string with some data that I want to display in a template. Since JSON also mentions Fluid arrays, I thought I could just take this JSON string and pass it to the liquid, telling her to treat it the same way as some other array, and use it in the template.
Thus, getting more speed and losing overhead (you do not need to separate JSON data to save it in the database, you can easily smooth it out in the liquid).
That would not work, at least not in the way I tried.
<f:alias map="{item.jsonData}"> {fieldname} </f:alias>
He, of course, complained that he received a string, not an array.
Should I create a viewhelper and make json_decode before returning the array to the liquid? Or is there a more native way?
Here's the main action of the controller:
public function showAction(\NAMESPACE\Myext\Domain\Model\Item $item) { $this->view->assign('item', $item); }
Urs
source share