json-ld / json-ld.org

JSON for Linked Data's documentation and playground site
https://json-ld.org/
Other
863 stars 152 forks source link

playground doesnt import structured data islands #753

Open melvincarvalho opened 3 years ago

melvincarvalho commented 3 years ago

An increasing deployment pattern for JSON-LD is in the form of a structured data island (ie JSON in a script tag)

However, when entering a web page into the playground it handles JSON and not HTML

I believe structured data islands are a valid deployment pattern in the JSON-LD 1.1 spec, so it would be nice if this could work with the many millions of sites out there that use this

Also, IMHO, this neatly completes a circle of creating a semantic web of both human and readable data, without requiring extra moving parts (AJAX, conneg, discovery)

gkellogg commented 3 years ago

They are defined in the spec, and there is code to support them in the underlying jsonld.js, but I think it’s been held up from being deployed due to some library issues. @davidlehn?

As a fallback, try using rdf.greggkellogg.net/distiller.

klacol commented 3 years ago

On the first read, I did not understand what a structures data island is. I came up to this issue, because the playground showed this error when parsing my sample page:

JSON markup - SyntaxError: Unexpected token < in JSON at position 1

I seems for me, that a structured data islands is the embedding of the JSON-LD data into a normal HTML document via the script tag. The playground seems to read the remote document as pure HTML and does not extract the JSON-LD data from the script tag.

To visualize and check the JSON-LD data in my page, I use this checker: https://search.google.com/test/rich-results

I would be nice, if the playground would try to use the embedded JSON-LD data in remote documents.

gkellogg commented 3 years ago

@davidlehn this should be possible, given the inherent support in jsonld.js. Presumably need an option to set the mime type to invoke that part of the algorithm?