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

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

From: Robin Berjon <robin@berjon.com>
Date: Mon, 6 Mar 2017 16:26:47 -0500
To: Karen <karen.cravens@gmail.com>, "schema.org Mailing List" <public-schemaorg@w3.org>
Message-ID: <7945df2b-c59e-f3e8-7bde-90102ac15196@berjon.com>
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.

-- 
• Robin Berjon - http://berjon.com/ - @robinberjon
• http://science.ai/ — intelligent science publishing
•
Received on Monday, 6 March 2017 21:27:17 UTC

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