I would like to know how can I insert a string into a javascript code like in the example below:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Restaurant",
"name": "Dave's Steak House",
"address": {
"@type": "PostalAddress",
"streetAddress": "148 W 51st St",
"addressLocality": "New York",
"addressRegion": "NY",
"postalCode": "10019",
"addressCountry": "US"
}
}
</script>
The problem is that when I try to insert the String between js it appears interpreted as HTML code with %
, &20
etc. I have tried with ?html
, escape
, no escape
, ?string
, ?js_string,
etc.
That's the String:
{
"@context": "http://schema.org",
"@type": "Restaurant",
"name": "Dave's Steak House",
"address": {
"@type": "PostalAddress",
"streetAddress": "148 W 51st St",
"addressLocality": "New York",
"addressRegion": "NY",
"postalCode": "10019",
"addressCountry": "US"
}
}
And the code:
${myString}