Re: [JSON] comments?

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.

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.

Hope this helps?!

Cheers,
Tom

-- 
Thomas Steiner, Research Scientist, Google Inc.
http://blog.tomayac.com, http://twitter.com/tomayac

Received on Friday, 25 March 2011 13:58:33 UTC