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

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