Subject: [Json] Comments by convention

From: "Pete Cordell" <[email-masked]>
Date: Fri, 7 Jun 2013 17:31:09 +0100

I along with many wish JSON included comments.  Since they can't 
retrospectively be added, what are the prospects of documenting a convention 
for including comments in a JSON message?

For example, something along the lines of:

2.6 Comments

JSON has no native ability to represent comments.  Instead, by convention, 
unless overridden by a protocol definition, comments can be represented by 
name/value pairs (a.k.a. members) with string values of the form:

    "//": "This is a comment"

Comments can be associated with a particular member within an object using a 
comment name of the form "// foo" where "foo" is the name of the member to 
which the comment applies.

For example:

    "order": {
            "//": "An order item",
            "// description": "A short description of the item ordered",
            "description": "1TB HDD",
            "// price": "The price in USD",
            "price": 123.45 }

How much goes up in smoke if we do that?

Pete Cordell
Codalogic Ltd
C++ tools for C++ programmers, http://codalogic.com
Read & write XML in C++, http://www.xml2cpp.com

---

From: Vinny A <[email-masked]>
Date: Fri, 7 Jun 2013 11:45:24 -0500

Adding to your proposal, I'd like it stated that comments are also first class name:value data pairs; ie if I call (pseudo code):

Jsonobject.get("// description");

Then I will get the value "A short description of the item ordered". Obviously this is also backward compatible.

-----------------
Vinny
www.jsontest.com

On Jun 7, 2013, at 11:31 AM, "Pete Cordell" <[email-masked]> wrote:

> I along with many wish JSON included comments.  Since they can't retrospectively be added, what are the prospects of documenting a convention for including comments in a JSON message?
> 
> JSON has no native ability to represent comments.  Instead, by convention, unless overridden by a protocol definition, comments can be represented by name/value pairs (a.k.a. members) with string values of the form:
> 
> Comments can be associated with a particular member within an object using a comment name of the form "// foo" where "foo" is the name of the member to which the comment applies.
> 
> For example:
> 
>   "order": {
>           "//": "An order item",
> _______________________________________________
> json mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/json

---

From: "Pete Cordell" <[email-masked]>
Date: Fri, 7 Jun 2013 19:38:32 +0100

Original Message From: "Vinny A"

> Adding to your proposal, I'd like it stated that comments are also first 
> class name:value data pairs; ie if I call (pseudo code):
>
> Then I will get the value "A short description of the item ordered". 
> Obviously this is also backward compatible.

Agreed.  It seems a nice feature, and you basically get it for free. 
There's not many days you can say that!

Pete.