Search code examples
jsonangularjsswig-template

SWIG json object parse into Client Side json


I am using Angularjs, but i guess it can be simple JavaScript.

What I have done:

console.log(JSON.parse({{{JSON.stringify(items)}}}));

items has the JSON object. I am getting the error:

Uncaught SyntaxError: Unexpected token o`.

I am not sure if it's the correct way to do this. Any idea?


Solution

  • I have figured it out:

    {{{items|raw|json_encode}}}