Re: [JSON] comments?

From: Thomas Steiner <tomac@google.com>
Subject: Re: [JSON] comments?
Date: Fri, 25 Mar 2011 08:57:25 -0500

> Hi Peter,
> 
>> Is it true that JSON doesn't have any commenting mechanism?
>
> Yes. Some use fake inline comments (counts as pure data):
> 
> {
>   "actualData": {...}
>   "comment": "This is a comment."
> }
> 
> ...others (e.g., the New York Times JSON) (illegally) use:
> 
> /* This is a comment. */
> {
>   "actualData": {...}
> }
> 
> This approach works when the data is eval'ed in JavaScript (evil,
> don't!), but it is definitively illegal JSON.

I find the first more evil.

> Missing comments is definitively a weak spot when JSON is used for,
> e.g., config files. It was not design to be used in that way, though.

Umm, just what was JSON designed for?  

I would think that "[JSON] is easy for humans to read and write" (from
http://json.org) would strongly support the inclusion of comments.

> Hope this helps?!

Indeed it does, and I notice that all three syntaxes appear to not allow
comments.  

> Cheers,
> Tom

I must admit to being surprised, so suprised that it has taken a couple
of days to notice the lack of comments.

peter

Received on Friday, 25 March 2011 14:15:46 UTC