JSON5

classic Classic list List threaded Threaded
32 messages Options
12
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

JSON5

J Decker
Since JSON is apparently part of the standard now, can JSON5 maybe be considered for addition?  It's a very slight change, and simplifies conversions.


Why does JSON have quoted field names anyway (which I could understand if they included spaced).

I searched archives and only came up with this result....





(although I would like to see the keyword 'undefined' also allowed as a value) which is just an 8 line addition.

Comments in JSON?  Wonderful!
Unquoted field names? Wonderful!


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Quoted map keys (was: Re: JSON5)

Carsten Bormann
On Jul 11, 2017, at 06:14, J Decker <[hidden email]> wrote:
>
> Why does JSON have quoted field names anyway (which I could understand if they included spaced).

Douglas Crockford has explained this bit of history in talks about JSON:

Originally, they weren’t quoting map keys (names of object members) if they looked like identifiers in JavaScript.  (In early JavaScript-based implementations, JSON data was directly fed as code into the JavaScript interpreter so there was no need to write a decoder.)

But then some application was using “do” as a map key.  “do” happens to be a reserved word in JavaScript, breaking the decoding process.  So they had to check if the map keys were reserved words and quote them in that case.  That set then would have to become part of the JSON specification.  Worse, the set of reserved word in JavaScript could (theoretically) change, so either the JSON specification would need to change, too, or the next version of JavaScript would no longer support direct use of JSON as JavaScript code.

So they decided to simply always quote, and that was that.

The approach to execute JSON as JavaScript code of course is history now, but JSON hasn’t changed back.

Actually, with RFC 7159 and ECMA 404 out and JSON very widely implemented, any proposal to change the JSON syntax is a complete non-starter.

(Most of these proposals come from people who notice that JSON is bad for conversing about data or for human input.  Well, that is not what JSON is meant for.  DO NOT USE JSON FOR CONVERSING ABOUT DATA OR FOR HUMAN INPUT.  JSON is an interchange format.  There are much better formats for humans inputting and conversing about JSON-modeled data, such as YAML, which is even a superset of JSON.  No point in messing around with JSON if the problem has already been solved.)

Of course, if saving bytes is your objective, you might want to look at CBOR.  I wonder when that is picked up by the JavaScript spec (there are libraries, of course).

Grüße, Carsten

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: JSON5

Dong Nguyen
In reply to this post by J Decker
Personally, I appreciate this idea. That's exactly how JSON should work. Sometimes I feel bad with current JSON specs: no comment, no trailing commas, double quotes, etc.

Regards,
Dong

On Tue, Jul 11, 2017 at 11:14 AM, J Decker <[hidden email]> wrote:
Since JSON is apparently part of the standard now, can JSON5 maybe be considered for addition?  It's a very slight change, and simplifies conversions.


Why does JSON have quoted field names anyway (which I could understand if they included spaced).

I searched archives and only came up with this result....





(although I would like to see the keyword 'undefined' also allowed as a value) which is just an 8 line addition.

Comments in JSON?  Wonderful!
Unquoted field names? Wonderful!


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




--
Dong Nguyen at Green Global

tweet me
plus me
git me

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: JSON5

Ryan Birmingham
My concern with single-lined comments is that json is often whitespace removed.

-Ryan Birmingham

On 11 July 2017 at 00:48, Dong Nguyen <[hidden email]> wrote:
Personally, I appreciate this idea. That's exactly how JSON should work. Sometimes I feel bad with current JSON specs: no comment, no trailing commas, double quotes, etc.

Regards,
Dong

On Tue, Jul 11, 2017 at 11:14 AM, J Decker <[hidden email]> wrote:
Since JSON is apparently part of the standard now, can JSON5 maybe be considered for addition?  It's a very slight change, and simplifies conversions.


Why does JSON have quoted field names anyway (which I could understand if they included spaced).

I searched archives and only came up with this result....





(although I would like to see the keyword 'undefined' also allowed as a value) which is just an 8 line addition.

Comments in JSON?  Wonderful!
Unquoted field names? Wonderful!


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




--
Dong Nguyen at Green Global

tweet me
plus me
git me

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss



_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: JSON5

Sebastian Malton
If that is a concern then allow C-style block comments or some other style of block comments 

Sebastian 

Sent: July 11, 2017 1:04 AM
Subject: Re: JSON5

My concern with single-lined comments is that json is often whitespace removed.

-Ryan Birmingham

On 11 July 2017 at 00:48, Dong Nguyen <[hidden email]> wrote:
Personally, I appreciate this idea. That's exactly how JSON should work. Sometimes I feel bad with current JSON specs: no comment, no trailing commas, double quotes, etc.

Regards,
Dong

On Tue, Jul 11, 2017 at 11:14 AM, J Decker <[hidden email]> wrote:
Since JSON is apparently part of the standard now, can JSON5 maybe be considered for addition?  It's a very slight change, and simplifies conversions.


Why does JSON have quoted field names anyway (which I could understand if they included spaced).

I searched archives and only came up with this result....





(although I would like to see the keyword 'undefined' also allowed as a value) which is just an 8 line addition.

Comments in JSON?  Wonderful!
Unquoted field names? Wonderful!


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




--
Dong Nguyen at Green Global

tweet me
plus me
git me

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss



_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: JSON5

Ryan Birmingham
In reply to this post by Ryan Birmingham
I believe that that's a reasonable solution, Sebastian.

-Ryan Birmingham

On 11 July 2017 at 01:12, Sebastian Malton <[hidden email]> wrote:
If that is a concern then allow C-style block comments or some other style of block comments 

Sebastian 

Sent: July 11, 2017 1:04 AM
Subject: Re: JSON5

My concern with single-lined comments is that json is often whitespace removed.

-Ryan Birmingham

On 11 July 2017 at 00:48, Dong Nguyen <[hidden email]> wrote:
Personally, I appreciate this idea. That's exactly how JSON should work. Sometimes I feel bad with current JSON specs: no comment, no trailing commas, double quotes, etc.

Regards,
Dong

On Tue, Jul 11, 2017 at 11:14 AM, J Decker <[hidden email]> wrote:
Since JSON is apparently part of the standard now, can JSON5 maybe be considered for addition?  It's a very slight change, and simplifies conversions.


Why does JSON have quoted field names anyway (which I could understand if they included spaced).

I searched archives and only came up with this result....





(although I would like to see the keyword 'undefined' also allowed as a value) which is just an 8 line addition.

Comments in JSON?  Wonderful!
Unquoted field names? Wonderful!


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




--
Dong Nguyen at Green Global

tweet me
plus me
git me

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: JSON5

J Decker
In reply to this post by Ryan Birmingham


On Mon, Jul 10, 2017 at 10:04 PM, Ryan Birmingham <[hidden email]> wrote:
My concern with single-lined comments is that json is often whitespace removed.

-Ryan Birmingham

On 11 July 2017 at 00:48, Dong Nguyen <[hidden email]> wrote:
Personally, I appreciate this idea. That's exactly how JSON should work. Sometimes I feel bad with current JSON specs: no comment, no trailing commas, double quotes, etc.


their quoted line continuations kinda bother me too... they say just escape the end... but then that's 
\  \r \n  -or- just \ \n   and if the \r is just a whitespace it should silently be ignored or something anyway....

but ya, I can see single line comments being an issue depending on the parser too.

 
Regards,
Dong

On Tue, Jul 11, 2017 at 11:14 AM, J Decker <[hidden email]> wrote:
Since JSON is apparently part of the standard now, can JSON5 maybe be considered for addition?  It's a very slight change, and simplifies conversions.


Why does JSON have quoted field names anyway (which I could understand if they included spaced).

I searched archives and only came up with this result....





(although I would like to see the keyword 'undefined' also allowed as a value) which is just an 8 line addition.

Comments in JSON?  Wonderful!
Unquoted field names? Wonderful!


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




--
Dong Nguyen at Green Global

tweet me
plus me
git me

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: JSON5

Don Griffin
In reply to this post by Ryan Birmingham
Seems like whitespace stripping is more of a serialization concern... and hence comments are moot.

Where comments are needed (and single line ones are handy) is human edited JSON and also not likely to be stripped.

Just my $2e-02

Best,
Don
--
Don Griffin
Sr Director of Engineering
Sencha, Inc.

On Tue, Jul 11, 2017 at 12:13 AM, Ryan Birmingham <[hidden email]> wrote:
I believe that that's a reasonable solution, Sebastian.

-Ryan Birmingham

On 11 July 2017 at 01:12, Sebastian Malton <[hidden email]> wrote:
If that is a concern then allow C-style block comments or some other style of block comments 

Sebastian 

Sent: July 11, 2017 1:04 AM
Subject: Re: JSON5

My concern with single-lined comments is that json is often whitespace removed.

-Ryan Birmingham

On 11 July 2017 at 00:48, Dong Nguyen <[hidden email]> wrote:
Personally, I appreciate this idea. That's exactly how JSON should work. Sometimes I feel bad with current JSON specs: no comment, no trailing commas, double quotes, etc.

Regards,
Dong

On Tue, Jul 11, 2017 at 11:14 AM, J Decker <[hidden email]> wrote:
Since JSON is apparently part of the standard now, can JSON5 maybe be considered for addition?  It's a very slight change, and simplifies conversions.


Why does JSON have quoted field names anyway (which I could understand if they included spaced).

I searched archives and only came up with this result....





(although I would like to see the keyword 'undefined' also allowed as a value) which is just an 8 line addition.

Comments in JSON?  Wonderful!
Unquoted field names? Wonderful!


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




--
Dong Nguyen at Green Global

tweet me
plus me
git me

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss



_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: JSON5

Jordan Harband
JSON already has comments:

```json
{
  "foo": "the 'foo' field is for putting important stuff!",
  "foo": "the real value for 'foo'"
}
```

On Mon, Jul 10, 2017 at 10:16 PM, Don Griffin <[hidden email]> wrote:
Seems like whitespace stripping is more of a serialization concern... and hence comments are moot.

Where comments are needed (and single line ones are handy) is human edited JSON and also not likely to be stripped.

Just my $2e-02

Best,
Don
--
Don Griffin
Sr Director of Engineering
Sencha, Inc.

On Tue, Jul 11, 2017 at 12:13 AM, Ryan Birmingham <[hidden email]> wrote:
I believe that that's a reasonable solution, Sebastian.

-Ryan Birmingham

On 11 July 2017 at 01:12, Sebastian Malton <[hidden email]> wrote:
If that is a concern then allow C-style block comments or some other style of block comments 

Sebastian 

Sent: July 11, 2017 1:04 AM
Subject: Re: JSON5

My concern with single-lined comments is that json is often whitespace removed.

-Ryan Birmingham

On 11 July 2017 at 00:48, Dong Nguyen <[hidden email]> wrote:
Personally, I appreciate this idea. That's exactly how JSON should work. Sometimes I feel bad with current JSON specs: no comment, no trailing commas, double quotes, etc.

Regards,
Dong

On Tue, Jul 11, 2017 at 11:14 AM, J Decker <[hidden email]> wrote:
Since JSON is apparently part of the standard now, can JSON5 maybe be considered for addition?  It's a very slight change, and simplifies conversions.


Why does JSON have quoted field names anyway (which I could understand if they included spaced).

I searched archives and only came up with this result....





(although I would like to see the keyword 'undefined' also allowed as a value) which is just an 8 line addition.

Comments in JSON?  Wonderful!
Unquoted field names? Wonderful!


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




--
Dong Nguyen at Green Global

tweet me
plus me
git me

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss



_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss



_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: JSON5

Dong Nguyen
@Jordan: I think that's just work-around, not official feature.

Dong

On Tue, Jul 11, 2017 at 12:31 PM, Jordan Harband <[hidden email]> wrote:
JSON already has comments:

```json
{
  "foo": "the 'foo' field is for putting important stuff!",
  "foo": "the real value for 'foo'"
}
```

On Mon, Jul 10, 2017 at 10:16 PM, Don Griffin <[hidden email]> wrote:
Seems like whitespace stripping is more of a serialization concern... and hence comments are moot.

Where comments are needed (and single line ones are handy) is human edited JSON and also not likely to be stripped.

Just my $2e-02

Best,
Don
--
Don Griffin
Sr Director of Engineering
Sencha, Inc.

On Tue, Jul 11, 2017 at 12:13 AM, Ryan Birmingham <[hidden email]> wrote:
I believe that that's a reasonable solution, Sebastian.

-Ryan Birmingham

On 11 July 2017 at 01:12, Sebastian Malton <[hidden email]> wrote:
If that is a concern then allow C-style block comments or some other style of block comments 

Sebastian 

Sent: July 11, 2017 1:04 AM
Subject: Re: JSON5

My concern with single-lined comments is that json is often whitespace removed.

-Ryan Birmingham

On 11 July 2017 at 00:48, Dong Nguyen <[hidden email]> wrote:
Personally, I appreciate this idea. That's exactly how JSON should work. Sometimes I feel bad with current JSON specs: no comment, no trailing commas, double quotes, etc.

Regards,
Dong

On Tue, Jul 11, 2017 at 11:14 AM, J Decker <[hidden email]> wrote:
Since JSON is apparently part of the standard now, can JSON5 maybe be considered for addition?  It's a very slight change, and simplifies conversions.


Why does JSON have quoted field names anyway (which I could understand if they included spaced).

I searched archives and only came up with this result....





(although I would like to see the keyword 'undefined' also allowed as a value) which is just an 8 line addition.

Comments in JSON?  Wonderful!
Unquoted field names? Wonderful!


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




--
Dong Nguyen at Green Global

tweet me
plus me
git me

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss



_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss



_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




--
Dong Nguyen at Green Global

tweet me
plus me
git me

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: JSON5

kai zhu

any significant degradation in json parsing-performance would impact the world wide web.  can anyone knowledgeable on js engines comment on parsing performance?

On Jul 11, 2017 15:39, "Dong Nguyen" <[hidden email]> wrote:
@Jordan: I think that's just work-around, not official feature.

Dong

On Tue, Jul 11, 2017 at 12:31 PM, Jordan Harband <[hidden email]> wrote:
JSON already has comments:

```json
{
  "foo": "the 'foo' field is for putting important stuff!",
  "foo": "the real value for 'foo'"
}
```

On Mon, Jul 10, 2017 at 10:16 PM, Don Griffin <[hidden email]> wrote:
Seems like whitespace stripping is more of a serialization concern... and hence comments are moot.

Where comments are needed (and single line ones are handy) is human edited JSON and also not likely to be stripped.

Just my $2e-02

Best,
Don
--
Don Griffin
Sr Director of Engineering
Sencha, Inc.

On Tue, Jul 11, 2017 at 12:13 AM, Ryan Birmingham <[hidden email]> wrote:
I believe that that's a reasonable solution, Sebastian.

-Ryan Birmingham

On 11 July 2017 at 01:12, Sebastian Malton <[hidden email]> wrote:
If that is a concern then allow C-style block comments or some other style of block comments 

Sebastian 

Sent: July 11, 2017 1:04 AM
Subject: Re: JSON5

My concern with single-lined comments is that json is often whitespace removed.

-Ryan Birmingham

On 11 July 2017 at 00:48, Dong Nguyen <[hidden email]> wrote:
Personally, I appreciate this idea. That's exactly how JSON should work. Sometimes I feel bad with current JSON specs: no comment, no trailing commas, double quotes, etc.

Regards,
Dong

On Tue, Jul 11, 2017 at 11:14 AM, J Decker <[hidden email]> wrote:
Since JSON is apparently part of the standard now, can JSON5 maybe be considered for addition?  It's a very slight change, and simplifies conversions.


Why does JSON have quoted field names anyway (which I could understand if they included spaced).

I searched archives and only came up with this result....





(although I would like to see the keyword 'undefined' also allowed as a value) which is just an 8 line addition.

Comments in JSON?  Wonderful!
Unquoted field names? Wonderful!


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




--
Dong Nguyen at Green Global

tweet me
plus me
git me

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss



_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss



_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




--
Dong Nguyen at Green Global

tweet me
plus me
git me

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: JSON5

J Decker
On Tue, Jul 11, 2017 at 3:48 AM, kai zhu <[hidden email]> wrote:

any significant degradation in json parsing-performance would impact the world wide web.  can anyone knowledgeable on js engines comment on parsing performance?

I wouldn't expect to replace JSON.xxx but rather add JSON5.xxx for those that require absolute speed over maintainability/flexibility.

that said...
 
it's based on crockford's original


and comparting with 

it's essentialy the same (err maybe not; a diff shows lots of diff)

------
I found some test data....
in data there's a handful of JSON files; I loaded these all into an array of strings and data.forEach( data=><JSON0/JSON5/JSON(node native)>.parse(data ) );

50 iterations took 

JSON(crockford ref): 2971ms
JSON5: 4688ms
JSON: 644ms

63.37% the speed of crockford refernce code (not quite half the speed)
13.7% the speed of Node's native JSON.parse().
-or-
1.57 times slower than crockford reference code.
7.32 times as slow as JSON.parse()


my own native code parser addon was about 1/2 as fast as node's, so I didn't flesh mine out to a great extent; but the modifications required to go from supporting no-quotes, single-or double quotes, comments, line continuation, Infinity/NaN values really shouldn't slow it down that much;  (mine dies on the test data; so that's a thing for another day; and will be hard to tell JSON vs JSON5 because It won't do JSON only anymore (maybe) ).


 
On Jul 11, 2017 15:39, "Dong Nguyen" <[hidden email]> wrote:
@Jordan: I think that's just work-around, not official feature.

Dong

On Tue, Jul 11, 2017 at 12:31 PM, Jordan Harband <[hidden email]> wrote:
JSON already has comments:

```json
{
  "foo": "the 'foo' field is for putting important stuff!",
  "foo": "the real value for 'foo'"
}
```

On Mon, Jul 10, 2017 at 10:16 PM, Don Griffin <[hidden email]> wrote:
Seems like whitespace stripping is more of a serialization concern... and hence comments are moot.

Where comments are needed (and single line ones are handy) is human edited JSON and also not likely to be stripped.

Just my $2e-02

Best,
Don
--
Don Griffin
Sr Director of Engineering
Sencha, Inc.

On Tue, Jul 11, 2017 at 12:13 AM, Ryan Birmingham <[hidden email]> wrote:
I believe that that's a reasonable solution, Sebastian.

-Ryan Birmingham

On 11 July 2017 at 01:12, Sebastian Malton <[hidden email]> wrote:
If that is a concern then allow C-style block comments or some other style of block comments 

Sebastian 

Sent: July 11, 2017 1:04 AM
Subject: Re: JSON5

My concern with single-lined comments is that json is often whitespace removed.

-Ryan Birmingham

On 11 July 2017 at 00:48, Dong Nguyen <[hidden email]> wrote:
Personally, I appreciate this idea. That's exactly how JSON should work. Sometimes I feel bad with current JSON specs: no comment, no trailing commas, double quotes, etc.

Regards,
Dong

On Tue, Jul 11, 2017 at 11:14 AM, J Decker <[hidden email]> wrote:
Since JSON is apparently part of the standard now, can JSON5 maybe be considered for addition?  It's a very slight change, and simplifies conversions.


Why does JSON have quoted field names anyway (which I could understand if they included spaced).

I searched archives and only came up with this result....





(although I would like to see the keyword 'undefined' also allowed as a value) which is just an 8 line addition.

Comments in JSON?  Wonderful!
Unquoted field names? Wonderful!





_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: JSON5

kai zhu
Appreciate the benchmarks.  57% slower than reference javascript-implementation is iffy.  Would still prefer comment from v8 / spidermonkey / chakra / etc implementers.  A concern would be if 20-100mb json data that currently parses natively fine in browsers might cause UX-freezing issues due to extra parsing overhead.  And again people rely on json in I/O protocols for its fast serialization / deserialization.

I’m against having separate JSON.xxx and JSON5.xxx extensions.  2 different json formats will lead to alot of confusion (like the current .js .mjs mess).  Frankly, I just use regular js files when I need commented json data, e.g.:

```
// data.js file
module.exports = {
   // comments
   foo: “bar"
};
```

Its not sexy, but its maintainable code 2 years down the road, without extra tools and libraries.

On Jul 11, 2017, at 7:37 PM, J Decker <[hidden email]> wrote:

On Tue, Jul 11, 2017 at 3:48 AM, kai zhu <[hidden email]> wrote:

any significant degradation in json parsing-performance would impact the world wide web.  can anyone knowledgeable on js engines comment on parsing performance?

I wouldn't expect to replace JSON.xxx but rather add JSON5.xxx for those that require absolute speed over maintainability/flexibility.

that said...
 
it's based on crockford's original


and comparting with 

it's essentialy the same (err maybe not; a diff shows lots of diff)

------
I found some test data....
in data there's a handful of JSON files; I loaded these all into an array of strings and data.forEach( data=><JSON0/JSON5/JSON(node native)>.parse(data ) );

50 iterations took 

JSON(crockford ref): 2971ms
JSON5: 4688ms
JSON: 644ms

63.37% the speed of crockford refernce code (not quite half the speed)
13.7% the speed of Node's native JSON.parse().
-or-
1.57 times slower than crockford reference code.
7.32 times as slow as JSON.parse()


my own native code parser addon was about 1/2 as fast as node's, so I didn't flesh mine out to a great extent; but the modifications required to go from supporting no-quotes, single-or double quotes, comments, line continuation, Infinity/NaN values really shouldn't slow it down that much;  (mine dies on the test data; so that's a thing for another day; and will be hard to tell JSON vs JSON5 because It won't do JSON only anymore (maybe) ).


 
On Jul 11, 2017 15:39, "Dong Nguyen" <[hidden email]> wrote:
@Jordan: I think that's just work-around, not official feature.

Dong

On Tue, Jul 11, 2017 at 12:31 PM, Jordan Harband <[hidden email]> wrote:
JSON already has comments:

```json
{
  "foo": "the 'foo' field is for putting important stuff!",
  "foo": "the real value for 'foo'"
}
```

On Mon, Jul 10, 2017 at 10:16 PM, Don Griffin <[hidden email]> wrote:
Seems like whitespace stripping is more of a serialization concern... and hence comments are moot.

Where comments are needed (and single line ones are handy) is human edited JSON and also not likely to be stripped.

Just my $2e-02

Best,
Don
--
Don Griffin
Sr Director of Engineering
Sencha, Inc.

On Tue, Jul 11, 2017 at 12:13 AM, Ryan Birmingham <[hidden email]> wrote:
I believe that that's a reasonable solution, Sebastian.

-Ryan Birmingham

On 11 July 2017 at 01:12, Sebastian Malton <[hidden email]> wrote:
If that is a concern then allow C-style block comments or some other style of block comments 

Sebastian 

Sent: July 11, 2017 1:04 AM
Subject: Re: JSON5

My concern with single-lined comments is that json is often whitespace removed.

-Ryan Birmingham

On 11 July 2017 at 00:48, Dong Nguyen <[hidden email]> wrote:
Personally, I appreciate this idea. That's exactly how JSON should work. Sometimes I feel bad with current JSON specs: no comment, no trailing commas, double quotes, etc.

Regards,
Dong

On Tue, Jul 11, 2017 at 11:14 AM, J Decker <[hidden email]> wrote:
Since JSON is apparently part of the standard now, can JSON5 maybe be considered for addition?  It's a very slight change, and simplifies conversions.


Why does JSON have quoted field names anyway (which I could understand if they included spaced).

I searched archives and only came up with this result....





(although I would like to see the keyword 'undefined' also allowed as a value) which is just an 8 line addition.

Comments in JSON?  Wonderful!
Unquoted field names? Wonderful!




_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: JSON5

doodad-js Admin

Hi,

 

For huge JSON/JSON5 files, I propose to add streaming support, with chunk per chunk parsing, and have a configurable size limit somewhere.

 

Claude Petit

 

From: kai zhu [mailto:[hidden email]]
Sent: Tuesday, July 11, 2017 9:05 AM
To: J Decker <[hidden email]>
Cc: es-discuss <[hidden email]>
Subject: Re: JSON5

 

Appreciate the benchmarks.  57% slower than reference javascript-implementation is iffy.  Would still prefer comment from v8 / spidermonkey / chakra / etc implementers.  A concern would be if 20-100mb json data that currently parses natively fine in browsers might cause UX-freezing issues due to extra parsing overhead.  And again people rely on json in I/O protocols for its fast serialization / deserialization.

 

I’m against having separate JSON.xxx and JSON5.xxx extensions.  2 different json formats will lead to alot of confusion (like the current .js .mjs mess).  Frankly, I just use regular js files when I need commented json data, e.g.:

 

```

// data.js file

module.exports = {

   // comments

   foo: “bar"

};

```

 

Its not sexy, but its maintainable code 2 years down the road, without extra tools and libraries.

 

On Jul 11, 2017, at 7:37 PM, J Decker <[hidden email]> wrote:

 

On Tue, Jul 11, 2017 at 3:48 AM, kai zhu <[hidden email]> wrote:

any significant degradation in json parsing-performance would impact the world wide web.  can anyone knowledgeable on js engines comment on parsing performance?

I wouldn't expect to replace JSON.xxx but rather add JSON5.xxx for those that require absolute speed over maintainability/flexibility.

 

that said...

 

it's based on crockford's original

 

 

and comparting with 

 

it's essentialy the same (err maybe not; a diff shows lots of diff)

 

------

I found some test data....

in data there's a handful of JSON files; I loaded these all into an array of strings and data.forEach( data=><JSON0/JSON5/JSON(node native)>.parse(data ) );

 

50 iterations took 

 

JSON(crockford ref): 2971ms

JSON5: 4688ms

JSON: 644ms

 

63.37% the speed of crockford refernce code (not quite half the speed)

13.7% the speed of Node's native JSON.parse().

-or-

1.57 times slower than crockford reference code.

7.32 times as slow as JSON.parse()

 

 

my own native code parser addon was about 1/2 as fast as node's, so I didn't flesh mine out to a great extent; but the modifications required to go from supporting no-quotes, single-or double quotes, comments, line continuation, Infinity/NaN values really shouldn't slow it down that much;  (mine dies on the test data; so that's a thing for another day; and will be hard to tell JSON vs JSON5 because It won't do JSON only anymore (maybe) ).

 

 

 

On Jul 11, 2017 15:39, "Dong Nguyen" <[hidden email]> wrote:

@Jordan: I think that's just work-around, not official feature.

 

Dong

 

On Tue, Jul 11, 2017 at 12:31 PM, Jordan Harband <[hidden email]> wrote:

JSON already has comments:

 

```json

{

  "foo": "the 'foo' field is for putting important stuff!",

  "foo": "the real value for 'foo'"

}

```

 

On Mon, Jul 10, 2017 at 10:16 PM, Don Griffin <[hidden email]> wrote:

Seems like whitespace stripping is more of a serialization concern... and hence comments are moot.

 

Where comments are needed (and single line ones are handy) is human edited JSON and also not likely to be stripped.

 

Just my $2e-02


Best,

Don

--

Don Griffin

Sr Director of Engineering

Sencha, Inc.

 

On Tue, Jul 11, 2017 at 12:13 AM, Ryan Birmingham <[hidden email]> wrote:

I believe that that's a reasonable solution, Sebastian.


-Ryan Birmingham

 

On 11 July 2017 at 01:12, Sebastian Malton <[hidden email]> wrote:

If that is a concern then allow C-style block comments or some other style of block comments 

 

Sebastian 

 

Sent: July 11, 2017 1:04 AM

Subject: Re: JSON5

 

My concern with single-lined comments is that json is often whitespace removed.


-Ryan Birmingham

 

On 11 July 2017 at 00:48, Dong Nguyen <[hidden email]> wrote:

Personally, I appreciate this idea. That's exactly how JSON should work. Sometimes I feel bad with current JSON specs: no comment, no trailing commas, double quotes, etc.

 

Regards,

Dong

 

On Tue, Jul 11, 2017 at 11:14 AM, J Decker <[hidden email]> wrote:

Since JSON is apparently part of the standard now, can JSON5 maybe be considered for addition?  It's a very slight change, and simplifies conversions.

 

 

Why does JSON have quoted field names anyway (which I could understand if they included spaced).

 

I searched archives and only came up with this result....

 

 

 

 

(although I would like to see the keyword 'undefined' also allowed as a value) which is just an 8 line addition.

 

Comments in JSON?  Wonderful!

Unquoted field names? Wonderful!

 

 

 

 

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

 


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: JSON5

J Decker
In reply to this post by J Decker
(combined a couple messages...)
On Tue, Jul 11, 2017 at 6:12 AM, Mike Samuel <[hidden email]> wrote:
>> Why does JSON have quoted field names anyway (which I could understand if
>> they included spaced).

>To avoid intersecting the reserved identifier set in languages that
>wanted to provide a JSON-like syntax for producing values that
>serialize to JSON.

that justification makes no sense; 'serialize to json' kinda voids any keyword argument; although, I vaguely remember a mention that crockford had some single regex expression that could parse json simply, so maybe it's part of that.  


 

(fixed error handling escaped quotes in strings that was causing mine to crash; so throwing in C++ Node Addon....) 

delta JSON(c): 2929
delta JSON5: 4632
delta JSON: 683
delta JSON(svfs): 1640  (before JSON5 extension)

delta JSON(c): 2891
delta JSON5: 4581
delta JSON: 647
delta JSON(svfs): 1631 (before JSON5 extension)

delta JSON(c): 2859
delta JSON5: 4483
delta JSON: 642
delta JSON(svfs): 1764 (after JSON5 extension)

delta JSON(c): 2860
delta JSON5: 4536
delta JSON: 641
delta JSON(svfs): 1762 (after JSON5 extension)

native code 2.5x faster than JSON5 and 1.62x faster than crockford reference code.

what's going to be in the browser is going to be more like the Node internal than any of the JS versions or my C++ Node.  addon version.


8% loss in mine; separated the test to test just native code, same test is 761ms; so think most of my loss is in the handoff between node and my addon.....

 
1.57 times slower than crockford reference code.
7.32 times as slow as JSON.parse()


----

it's obvious(to me anyway) that having a javascript version of either (reference code) or JSON5 is going to be slower than a builtin facility.  Even a node Addon isn't really that effective, losing half the time just in interchanging between V8 and the outside world.

 

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: JSON5

Mike Samuel
On Tue, Jul 11, 2017 at 12:57 PM, J Decker <[hidden email]> wrote:

> (combined a couple messages...)
> On Tue, Jul 11, 2017 at 6:12 AM, Mike Samuel <[hidden email]> wrote:
>>> Why does JSON have quoted field names anyway (which I could understand if
>>> they included spaced).
>
>>To avoid intersecting the reserved identifier set in languages that
>>wanted to provide a JSON-like syntax for producing values that
>>serialize to JSON.
>
> that justification makes no sense; 'serialize to json' kinda voids any

I don't know that (serialize to json) does void that argument, but if
you're using a function to serialize to JSON and gzipping message
bodies, then unquoted keys offer no benefit.

One concern was that JSON was meant as a glue for networked systems,
so to get adoption it should look familiar and also have consistent
semantics to novice programmers trying to glue frontends and backends
together.

Avoiding reserved keywords is one problem, but there are others in this vein.

Consider a novice programmer trying to glue together a Python backend
and a JavaScript frontend.  If you train novices by example to omit
quotes then they will run into semantic differences between
    a = "b"
    myJson = { a: "v" }
in those two languages, prompting them to give up and use XML.


> keyword argument; although, I vaguely remember a mention that crockford had
> some single regex expression that could parse json simply, so maybe it's
> part of that.

Crockford did have such a regex.
It is in section 6 of https://tools.ietf.org/html/rfc4627
"""
   This can be quickly determined in JavaScript with two
   regular expressions and calls to the test and replace methods.

      var my_JSON_object = !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(
             text.replace(/"(\\.|[^"\\])*"/g, ''))) &&
         eval('(' + text + ')');
"""

That claim is suspect.  It worked around an earlier claim which was bypassd.
http://blog.mindedsecurity.com/2011/08/ye-olde-crockford-json-regexp-is.html by

    +{ "valueOf": self["location"],
    "toString": []["join"],
    0: "javascript:alert(1)",
    length: 1
    }
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Quoted map keys (was: Re: JSON5)

Don Griffin
In reply to this post by Carsten Bormann
​I don't think your "DO NOT USE JSON ... FOR HUMAN INPUT" notion was noticed by ... anyone really :)​

Node.js has package.json, other package managers use component.json, editors use settings.json and some even throw that file in to a text editor as the configuration UI. AFAICT this whole notion of making JSON more like JavaScript object notation is because human's do interact with JSON quite often and want some of the little creature comforts.

JSON5 may be overkill, but it seem unquoted keys and comments (and real dates) would be welcome by us unfortunate humans. :)




Best,
Don
--
Don Griffin
Sr Director of Engineering
Sencha, Inc.

On Mon, Jul 10, 2017 at 11:33 PM, Carsten Bormann <[hidden email]> wrote:
On Jul 11, 2017, at 06:14, J Decker <[hidden email]> wrote:
>
> Why does JSON have quoted field names anyway (which I could understand if they included spaced).

Douglas Crockford has explained this bit of history in talks about JSON:

Originally, they weren’t quoting map keys (names of object members) if they looked like identifiers in JavaScript.  (In early JavaScript-based implementations, JSON data was directly fed as code into the JavaScript interpreter so there was no need to write a decoder.)

But then some application was using “do” as a map key.  “do” happens to be a reserved word in JavaScript, breaking the decoding process.  So they had to check if the map keys were reserved words and quote them in that case.  That set then would have to become part of the JSON specification.  Worse, the set of reserved word in JavaScript could (theoretically) change, so either the JSON specification would need to change, too, or the next version of JavaScript would no longer support direct use of JSON as JavaScript code.

So they decided to simply always quote, and that was that.

The approach to execute JSON as JavaScript code of course is history now, but JSON hasn’t changed back.

Actually, with RFC 7159 and ECMA 404 out and JSON very widely implemented, any proposal to change the JSON syntax is a complete non-starter.

(Most of these proposals come from people who notice that JSON is bad for conversing about data or for human input.  Well, that is not what JSON is meant for.  DO NOT USE JSON FOR CONVERSING ABOUT DATA OR FOR HUMAN INPUT.  JSON is an interchange format.  There are much better formats for humans inputting and conversing about JSON-modeled data, such as YAML, which is even a superset of JSON.  No point in messing around with JSON if the problem has already been solved.)

Of course, if saving bytes is your objective, you might want to look at CBOR.  I wonder when that is picked up by the JavaScript spec (there are libraries, of course).

Grüße, Carsten

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Quoted map keys (was: Re: JSON5)

J Decker
I didn't get that mail at all; I assume it was a mistaken private response?

On Tue, Jul 11, 2017 at 10:23 PM, Don Griffin <[hidden email]> wrote:
​I don't think your "DO NOT USE JSON ... FOR HUMAN INPUT" notion was noticed by ... anyone really :)​

Node.js has package.json, other package managers use component.json, editors use settings.json and some even throw that file in to a text editor as the configuration UI. AFAICT this whole notion of making JSON more like JavaScript object notation is because human's do interact with JSON quite often and want some of the little creature comforts.

JSON5 may be overkill, but it seem unquoted keys and comments (and real dates) would be welcome by us unfortunate humans. :)




Best,
Don
--
Don Griffin
Sr Director of Engineering
Sencha, Inc.

On Mon, Jul 10, 2017 at 11:33 PM, Carsten Bormann <[hidden email]> wrote:
On Jul 11, 2017, at 06:14, J Decker <[hidden email]> wrote:
>
> Why does JSON have quoted field names anyway (which I could understand if they included spaced).

Douglas Crockford has explained this bit of history in talks about JSON:

Originally, they weren’t quoting map keys (names of object members) if they looked like identifiers in JavaScript.  (In early JavaScript-based implementations, JSON data was directly fed as code into the JavaScript interpreter so there was no need to write a decoder.)

But then some application was using “do” as a map key.  “do” happens to be a reserved word in JavaScript, breaking the decoding process.  So they had to check if the map keys were reserved words and quote them in that case.  That set then would have to become part of the JSON
I see.  keywords in that direction.
 
specification.  Worse, the set of reserved word in JavaScript could (theoretically) change, so either the JSON specification would need to change, too, or the next version of JavaScript would no longer support direct use of JSON as JavaScript code.

So they decided to simply always quote, and that was that.

The approach to execute JSON as JavaScript code of course is history now, but JSON hasn’t changed back.

Actually, with RFC 7159 and ECMA 404 out and JSON very widely implemented, any proposal to change the JSON syntax is a complete non-starter.

I'm not proposing any change; I was proposing another facility JSON5 in parallel to the existing JSON.  Although JSON5 being a superset of JSON and there not being any immediate issue with using JSON with JSON5, except it would be impossible to knowing whether a platform actually has JSON5 support in 'JSON' namespace.  It would be much more clear if it was in a separate namespace entirely.  
but all of that is about parse(); on the side of stringify, if the JSON original was changed, it would start generating invalid output that existing JSON readers would not work with, sounds like a bad plan also.  

Well it appears JSON5 is trying to stay at ES5 level (some sort of matching identifier there) and as such won't support `(back-tick) quoted strings.

So I don't care so much.

and I don't think tail commas in arrays don't behave correctly.

(Most of these proposals come from people who notice that JSON is bad for conversing about data or for human input.  Well, that is not what JSON is meant for.  DO NOT USE JSON FOR CONVERSING ABOUT DATA OR FOR HUMAN INPUT.  JSON is an interchange format.  There are much better formats for humans inputting and conversing about JSON-modeled data, such as YAML, which is even a superset of JSON.  No point in messing around with JSON if the problem has already been solved.)

Of course, if saving bytes is your objective, you might want to look at CBOR.  I wonder when that is picked up by the JavaScript spec (there are libraries, of course).

Grüße, Carsten

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss



_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Quoted map keys (was: Re: JSON5)

Carsten Bormann
On Jul 12, 2017, at 15:01, J Decker <[hidden email]> wrote:
>
> I didn't get that mail at all; I assume it was a mistaken private response?

Most likely, this is just a result of gmail not liking mail from people at universities.

But again, if people want a JSON superset for humans, that (*) has been around for more than a decade, so I don’t know why another one has to be invented every week (except that it is easy to invent one and it is a pleasant alternative to actually working on something useful).

Grüße, Carsten

(*) YAML, in case you wondered.  No, it doesn’t matter that it is a different color of bikeshed than you might have imagined; other people don’t like JSON5/HJSON/your-JSON-hack-of-the-week either.

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Quoted map keys (was: Re: JSON5)

Michał Wadas
Having native language support for YAML would be great too...

On Wed, Jul 12, 2017 at 3:19 PM, Carsten Bormann <[hidden email]> wrote:
On Jul 12, 2017, at 15:01, J Decker <[hidden email]> wrote:
>
> I didn't get that mail at all; I assume it was a mistaken private response?

Most likely, this is just a result of gmail not liking mail from people at universities.

But again, if people want a JSON superset for humans, that (*) has been around for more than a decade, so I don’t know why another one has to be invented every week (except that it is easy to invent one and it is a pleasant alternative to actually working on something useful).

Grüße, Carsten

(*) YAML, in case you wondered.  No, it doesn’t matter that it is a different color of bikeshed than you might have imagined; other people don’t like JSON5/HJSON/your-JSON-hack-of-the-week either.

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
12
Loading...