Make sure JSON is safe to include in HTML <script> tags (fixes #985)