W3C home > Mailing lists > Public > public-schemaorg@w3.org > March 2017

Embedding JSON with <script> tags inside <script> tags

From: Karen <karen.cravens@gmail.com>
Date: Mon, 6 Mar 2017 15:55:08 -0500
Message-ID: <CABP8dGLOiYRvxav+tB1pYpfGmgtUUhsEHtSuuA=VXtU25dNH7w@mail.gmail.com>
To: "schema.org Mailing List" <public-schemaorg@w3.org>
I am attempting to build a webpage with its own WebPage representation
embedded in it, and am running into a little issue.

Sometimes the webpage includes, say, an embedded Instagram or Imgur or
what-have-you, which includes a <script>. You put that inside the <script
type="application/ld+json">, though, and Firefox sees the embedded
</script> and goes "Okay, done!" and spews the rest of the JSON into the
page as part of the HTML. Perfectly logical, but not what I want to have
happen.

My question then is, what's an appropriate way to escape the JSON while
still letting Google et al. parse it properly?
Received on Monday, 6 March 2017 20:58:48 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:12:34 UTC