The advanced context usage for JSON+LD authorizes the use of an array. https://w3c.github.io/json-ld-syntax/#advanced-context-usage Nothing is said in the section about a restriction in embedding JSON+LD in html documents https://w3c.github.io/json-ld-syntax/#embedding-json-ld-in-html-documents So the square bracket syntax is failing in Safari: ``` data:text/html,%20%20%20%20<script%20type="application/ld+json">[{"@context":%20"https://schema.org"}]</script> ``` with ``` TypeError: undefined is not an object (evaluating 'r["@context"].toLowerCase') ``` while this is working. ``` <script type="application/ld+json">{"@context": "https://schema.org"}</script> ``` The minimal test case to reproduce the issue is ``` <script type="application/ld+json">[]</script> ``` In both Chrome and Firefox, this syntax is accepted.
<rdar://problem/108352610>
I have moved the radar to Safari, as this is not handled on WebKit side, but Safari side.
Karl, is there anywhere the progress of the issue can be tracked publicly?
Oh yes I dropped the ball about that. So one side WebKit doesn't suport JSON+LD in the engine. And the other Safari just needs the data as-is, so basically not to evaluate but just load it. Let see if there's an intermediary solution here.
Xidorn, Do you know about an app or a current website with a usage for this construct/syntax?
Yes, Canva's logout templates page currently uses this syntax: https://www.canva.com/templates/ (If you have Canva account, you need to logout or use private mode to access). I think we are fixing it, so I can't say how long it would keep being like it. Its current content is: ``` [{"@context":"https:\u002F\u002Fschema.org","@type":"WebSite","url":"https:\u002F\u002Fwww.canva.com\u002Ftemplates\u002F","potentialAction":[{"@type":"SearchAction","target":"https:\u002F\u002Fwww.canva.com\u002Ftemplates\u002Ftemplates\u002F?query={search_term_string}","query-input":"required name=search_term_string"}]}] ```
Thanks a lot!
Xidorn, this is still being discussed to find the origin of the issue and if it is something to fix on Safari side.