News for hackers. Stuff that matters.
Re:JSON5 is a proposed extension to JSON by mmastrac on Saturday March 01, 2014 @04:26PM (#7326189)
I love this concept; my only concern is that by adding comments, it becomes difficult to round-trip a JSON document. XML has the concept of comment nodes that can survive a round-trip, but there's no easy way to do this in JSON. Perhaps you could limit where comments could go (ie: tagging object properties or array items only) and add a "__comments__" property to an object and/or list that contains the matching comments for the items in the object and/or array.

Also, please add ISO-8601 dates (repeating my comment below)!

{ timestamp: new Date("2007-04-05T14:30Z") }

Re:JSON5 is a proposed extension to JSON by ollysb on Saturday March 01, 2014 @05:09PM (#7326375)
For the love of god yes! a standardised date format is the only thing that really needs changing in json.
Re:JSON5 is a proposed extension to JSON by TazeTSchnitzel on Sunday March 02, 2014 @10:10AM (#7329345)
We already have a standardised date format, as such. A specific subset of ISO 8601:

  > JSON.stringify(new Date())
  "2014-03-02T15:08:55.309Z"
Re:JSON5 is a proposed extension to JSON by hcarvalhoalves on Saturday March 01, 2014 @06:13PM (#7326609)
What's the benefit of cluttering JSON with a constructor like new Date(...) when you can just standardize on ISO-8601 strings? JSON is not supposed to be eval'ed anymore.
Re:JSON5 is a proposed extension to JSON by mmastrac on Saturday March 01, 2014 @06:17PM (#7326632)
JSON is JS. If I manually create a JSON document, it should also be valid in the context of code. And strings are not dates -- they are strings. That's why we have boolean and number literals.
Re:JSON5 is a proposed extension to JSON by bennyg on Sunday March 02, 2014 @12:39AM (#7327869)
So many other languages use JSON as a data format that keeping a weird constructor call in there would do more harm than good. Especially since you can keep the formatting code in your codebase and invoke that when you need to use that property.
Re:JSON5 is a proposed extension to JSON by DougBTX on Sunday March 02, 2014 @07:10AM (#7328846)
We had a bug once when some logger output happened to get passed through JSON. The receiving code expected arrays of strings, but at some point one of the records happened to just contain a date. That ended up getting deserialised as a real Date object, not a string, which obviously broke. Using the same representation for different data types just seems to be asking for bugs.
Re:JSON5 is a proposed extension to JSON by cjfont on Sunday March 02, 2014 @08:02AM (#7328993)
The problem is that your code should have been expecting that field to be a string and nothing else, and other fields that contain dates to be a date and nothing else. In other words, if you're parsing JSON in this manner you need to apply some sort of schema to the data or have another field in the record denote the datatype. Anytime you're trying to auto-magically detect the datatype of the field, you're gonna have a bad time.
Re:JSON5 is a proposed extension to JSON by da4c30ff on Sunday March 02, 2014 @03:37AM (#7328316)
What is wrong with standard unix timestamps?
Re:JSON5 is a proposed extension to JSON by berdario on Sunday March 02, 2014 @04:35AM (#7328451)
There's not a bijection between UTC time and "standard unix timestamps" due to leap seconds

if you encode TAI in a unix timestamp, this would be a solved problem, but due to the fact that you cannot encode the time zone in the "unix timestamp datatype", you'd also have to handle cases in which people chose another timezone.

This makes it good enough for storing data (it'd be nice if the size of the data type would be explicit) but suboptimal for interoperability with other systems that could be using a different standard

either you encode the timezone in a different field in your JSON, or someone (the JSON5 people?) could define a literal for timestamps like:

t+1393752828Z (this would also eliminate the ambiguity between timestamps and number literals)

Re:JSON5 is a proposed extension to JSON by masklinn on Sunday March 02, 2014 @04:17AM (#7328412)
Numbers, booleans, and null should be removed. What's wrong with using strings for every value?
Re:JSON5 is a proposed extension to JSON by SigmundA on Saturday March 01, 2014 @07:36PM (#7327018)
Yes please. I thought this would be listed first when I clicked on the link.