W3C home > Mailing lists > Public > public-vocabs@w3.org > November 2013

Re: JSON-LD in examples invalid due to comments

From: Dan Brickley <danbri@google.com>
Date: Thu, 28 Nov 2013 10:54:36 +0000
Message-ID: <CAK-qy=54Jm-J4VY_KFTTt9MBknFSiyfxbbZMg=z2kA+0cdsmng@mail.gmail.com>
To: Markus Lanthaler <markus.lanthaler@gmx.net>, Sam Goto <goto@google.com>
Cc: W3C Web Schemas Task Force <public-vocabs@w3.org>
On 28 November 2013 10:45, Markus Lanthaler <markus.lanthaler@gmx.net> wrote:
> Hi,
>
> I've just realized that all (?) JSON-LD examples in schema.org are invalid
> since they include comments. Just as JSON, JSON-LD doesn't support comments.
>
> Example 1 of http://schema.org/Action for instance begins as follows:
>
>   <script type="application/ld+json">
>     // John listened to Pink with Steve at Anna's appartment on his iPod.
>   {
>     "@context": "http://schema.org",
>     "@type": "ListenAction",
>     ...
>
> The second line turns this into invalid JSON(-LD). It should thus be
> rewritten to
>
>   <script type="application/ld+json">
>   {
>     "@context": "http://schema.org",
>     "@type": "ListenAction",
>     ...
>
>
> Would it be possible to remove those comments at the beginning of all
> examples? I fear that otherwise a lot of people will adapt this style which
> will lead to severe interoperability problems.

Fair point, thanks. I took a look around at commenting options for
JSON-LD recently, and it's pretty bleak. Some people are using
repeated keys, others using predictably named alternate keys. For
JSON-LD I'm not aware of an idiom that doesn't give rise to unwanted
triples, but perhaps there's some hack possible?

This does make me wonder about the W3C spec for embedding JSON-LD in
HTML, http://www.w3.org/TR/2013/PR-json-ld-20131105/#embedding-json-ld-in-html-documents
... whether it would be wrong, bad and ugly to use HTML's inline
comment syntax, i.e. <!-- ... -->.

For the schema.org docs, we should probably just move the comments out
of the <script>.

cheers,

Dan
Received on Thursday, 28 November 2013 10:55:03 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:29:35 UTC