I receive a jsonfrom the server when loading a page, and it gets populated in the page using Handelbars.java
. Till now everything's fine.
However I would like to get that jsonobject and store it on a javascriptobject this is where I fail.
When I try to store it on a javascript object I do the following :
var jsObject = "{{output.items}}"; // the output.items is the JSON retrieved on the template
I get the following ("e;
and line breaks interpreted) :
{
"profile": {
"name": "copernic",
"email": "copernic@cop.com"
}
....
}
When I should get the following (without line breaks interpreted) :
{
"profile": {
"name": "copernic",
"email": "copernic@cop.com"
}
....
}
So it throws me an error on javascriptUncaught SyntaxError: Unexpected token ILLEGAL
.
When printing the json on the HTML template using <pre>{{output}}</pre>
it looks just fine.
Do you have any idea about how can I store the jsonreturned from the server on page loading on a javascriptobject as I don't have much control of it since it's NOT coming with json?
Thank you.
{{profile.name}}
` or again in JS : `var name = "{{profile.name}}"`. But the issue is when I want to assign the whole object to a JS variable – Aug 29 '15 at 15:47