Question

This is the format that Google's "About Structured Data Markup Helper" provides:

<script type="application/ld+json">
{
  "@context": "http://json-ld.org/contexts/person.jsonld",
  "@id": "http://dbpedia.org/resource/John_Lennon",
  "name": "John Lennon",
  "born": "1940-10-09",
  "spouse": "http://dbpedia.org/resource/Cynthia_Lennon"
}
</script>

Can I remove the line breaks?

<script type="application/ld+json">{"@context": "http://json-ld.org/contexts/person.jsonld", "@id": "http://dbpedia.org/resource/John_Lennon", "name": "John Lennon", "born": "1940-10-09", "spouse": "http://dbpedia.org/resource/Cynthia_Lennon"}</script>
Was it helpful?

Solution

Yes, you can use it like that. JSON-LD (resp. JSON) doesn’t define that these line breaks are meaningful.

RFC 4627, JSON Grammar:

Insignificant whitespace is allowed before or after any of the six structural characters.

  ws = *(
            %x20 /              ; Space
            %x09 /              ; Horizontal tab
            %x0A /              ; Line feed or New line
            %x0D                ; Carriage return
        )
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top