10 Replies - 5279 Views - Last Post: 14 October 2013 - 12:43 PM

#1 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3485
  • View blog
  • Posts: 10,043
  • Joined: 08-June 10

[News] JSON standard defined

Post icon  Posted 11 October 2013 - 05:03 AM

The JSON Data Interchange Format has been put into an official ECMA standard: ECMA-404 (no, that’s not a file not found).
Is This A Good Question/Topic? 2
  • +

Replies To: [News] JSON standard defined

#2 Curtis Rutland  Icon User is online

  • (╯°□°)╯︵ (~ .o.)~
  • member icon


Reputation: 4433
  • View blog
  • Posts: 7,702
  • Joined: 08-June 10

Re: [News] JSON standard defined

Posted 11 October 2013 - 07:10 AM

"ECMA-404" is an ominous name :D

Do they still not allow for trailing commas?
Was This Post Helpful? 0
  • +
  • -

#3 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3485
  • View blog
  • Posts: 10,043
  • Joined: 08-June 10

Re: [News] JSON standard defined

Posted 11 October 2013 - 07:36 AM

why should they allow a trailing comma?
Was This Post Helpful? 0
  • +
  • -

#4 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1138
  • View blog
  • Posts: 7,105
  • Joined: 07-September 06

Re: [News] JSON standard defined

Posted 11 October 2013 - 07:38 AM

Nice find, and @curtis, they still don't allow for trailing commas in objects or arrays. It is at least a nice and small standard.

@Dormilich, actually a lot of programming languages do allow you to have trailing commas in arrays. It simplifies the programs for generating code since you don't need to check if there is another item in the array or not before adding the comma.
Was This Post Helpful? 0
  • +
  • -

#5 Curtis Rutland  Icon User is online

  • (╯°□°)╯︵ (~ .o.)~
  • member icon


Reputation: 4433
  • View blog
  • Posts: 7,702
  • Joined: 08-June 10

Re: [News] JSON standard defined

Posted 11 October 2013 - 11:23 AM

Exactly. It's a small feature that provides a small convenience. Not the end of the world without it, but nice to have.
Was This Post Helpful? 0
  • +
  • -

#6 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3215
  • View blog
  • Posts: 10,785
  • Joined: 12-December 12

Re: [News] JSON standard defined

Posted 11 October 2013 - 11:29 AM

I'm probably (well, I'm sure I am ;)) alone in this, but I prefer that it not allow a trailing comma. It should be an easy habit to break and it may indicate that the author intended to put something after the comma.

I appreciate it is a nuisance, but once you've made this error once or twice you are not likely to repeat it (often..).
Was This Post Helpful? 0
  • +
  • -

#7 Curtis Rutland  Icon User is online

  • (╯°□°)╯︵ (~ .o.)~
  • member icon


Reputation: 4433
  • View blog
  • Posts: 7,702
  • Joined: 08-June 10

Re: [News] JSON standard defined

Posted 11 October 2013 - 11:37 AM

It's not so much about the error, it's about the convenience. It hurts nothing, makes it easier to add lines, and makes tooling simpler (because they don't have to check for and remove trailing commas. C# allows for them, and I've found it convenient. But again, nothing to cry over if I don't ever get it.
Was This Post Helpful? 0
  • +
  • -

#8 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3485
  • View blog
  • Posts: 10,043
  • Joined: 08-June 10

Re: [News] JSON standard defined

Posted 11 October 2013 - 03:37 PM

look at it this way, you need extra code to implement a trailing comma. and not every language is as forgiving as, say, PHP or JS.
Was This Post Helpful? 0
  • +
  • -

#9 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1138
  • View blog
  • Posts: 7,105
  • Joined: 07-September 06

Re: [News] JSON standard defined

Posted 11 October 2013 - 03:55 PM

Actually, I believe that statement needs some clarification. If I am writing a program:

for(int i = 0; i < 100; i++){
  cout << i << ", ";
}


I actually need more code to get rid of the trailing comma.

However, if I am writing a processor for that code, you are correct in saying that I'd need to be able to deal with the trailing comma. But most languages have a fairly easy way of accomplishing that (c++ again):

string trailingComma = "1, 2, 3, 4, 5, ";
size_t lastComma = trailingComma.rfind(", ");
if(lastComma != string::npos && lastComma == trailingComma.size() - 2){
  trailingComma = trailingComma.substr(0, trailingComma.size() - 2);
}



Note, I haven't tested the code.
Was This Post Helpful? 0
  • +
  • -

#10 ishkabible  Icon User is offline

  • spelling expret
  • member icon




Reputation: 1622
  • View blog
  • Posts: 5,709
  • Joined: 03-August 09

Re: [News] JSON standard defined

Posted 14 October 2013 - 12:39 PM

Why are they using those stupid flowcharts? Can't they just use grammars like normal standards? I follow grammars quite well. Those flow charts are much harder to follow from the stand point of having to write a parser.

note:
They do not allow a trailing comma in arrays or objects. Look at the flow charts(grammar rules) for objects and arrays pages 6 and 7 respectively. Figures 2 and 3 to be precise.

note2:
That was the easiest standard in the world to read. I feel like implementing this now in haskell.

This post has been edited by ishkabible: 14 October 2013 - 12:43 PM

Was This Post Helpful? 0
  • +
  • -

#11 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3485
  • View blog
  • Posts: 10,043
  • Joined: 08-June 10

Re: [News] JSON standard defined

Posted 14 October 2013 - 12:43 PM

Quote

Why are they using those stupid flowcharts? Can't they just use grammars like normal standards?

I guess they used the flow charts from json.org.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1