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

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

From: Karen <karen.cravens@gmail.com>
Date: Mon, 6 Mar 2017 17:15:01 -0500
Message-ID: <CABP8dGK6wSVL1yev9iiRQ1hk5StSi_OO6YjtFboAjZ+wrQ4QMQ@mail.gmail.com>
Cc: "schema.org Mailing List" <public-schemaorg@w3.org>
On Mon, Mar 6, 2017 at 4:26 PM, Robin Berjon <robin@berjon.com> wrote:

> On 06/03/2017 15:55 , Karen wrote:
> > My question then is, what's an appropriate way to escape the JSON while
> > still letting Google et al. parse it properly?
> If I understand your problem correctly, you need the following (or its
> equivalent in whatever language you're using):
>   JSON.stringify(obj).replace(/<\/script/gi, '<\\u002fscript');
> On the text value to set on the LD script element.

Thanks, but that's not quite the problem - I'm going to have to escape the
JSON somehow to fix the local page, yes, but the problem is finding a way
to do it that things that consume it will recognize. Far as I can see,
there's no standard property on a <script> to indicate that the contents
need any preprocessing. So if I escape the JSON, I'm expecting Google to
happily index the sites as being named "less-than-aitch-one-greater-than
Site Name less-than-slash-aitch-one-greater-than" which is... not quite
what I want.
Received on Monday, 6 March 2017 22:15:34 UTC

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