Live data from Hacker News

The Fixing-JSON Conversation

tbray.org

51–55 of 55 posts

Re: The Fixing-JSON Conversation

#51

Earlier quoted context omitted.

> He summarized the most upvoted posts from the last thread [1] really well. I feel like he glossed right past the objections to the biggest and (to my mind) most destructive proposed change, the commas-to-whitespace thing; in fact doubles down on it (let's just declare that commas are whitespace! That surely won't confuse anyone!)

I've written a few JSON parsers over the years that treat commas as whitespace. The grammar is simpler and the parser is faster as result. As long as one always emits standards-compliant JSON there's no problem. Had the JSON standard supported ECMAScript array holes [1,,,2,,3] this grammar shortcut would not have been possible. But luckily that's not the case.

Well, that's the thing, though: sure, for machine parsing it really doesn't matter what you use as a delimiter.

But the only reason to get rid of commas is to eliminate the trailing comma problem, which only occurs when hand-editing JSON. Replacing that with whitespace, or worse both whitespace and commas, would be a lot more prone to hand-editing errors, I think, than would the much less drastic change of allowing trailing commas. Or better still of just leaving JSON as is and letting people use a more robust protocol, if that fits their needs, or pre-parsing whatever special snowflake variations they want into standards-compliant JSON.

I'm more or less in agreement with the commenter on his site who said

> this entire proposal pretty much comes down to "I like JSON, but need more and am too lazy to write the extra 3 line wrapper to process type 'x'." I'd say no thanks. https://www.tbray.org/ongoing/When/201x/2016/08/20/Fixing-JS...

Re: The Fixing-JSON Conversation

#52

Earlier quoted context omitted.

> It would be great to have a Genshi-like templating language for JSON, tightly integrated with JavaScript the same way Genshi is integrated with Python. But… that already exists. It's called "Python". Just define your data structure using bog-standard Python and serialise it.

What I mean is using JSON as the syntax, and JavaScript as the expression and scripting language. Zope has this supposedly "restricted subset" of Python that you're allowed to use as expressions and scripts, but it's missing important features and isn't meaningfully safe from a paranoid security perspective, and you end up having to drop down to lower level Zope external methods to write real Python code, which is ve…

> What I mean is using JSON as the syntax, and JavaScript as the expression and scripting language.

… it's the exact same process except with Javascript as the language? Generate your JS datastructure then JSON.stringify it? I don't understand what the issue is or why you'd want a templating language when much of JSON's point is that it matches directly to common standard datastructures.

Re: The Fixing-JSON Conversation

#53

Earlier quoted context omitted.

> The only reliable time stamp is UTC without leap seconds. That doesn't make a lot of sense, as UTC does have leap seconds. It is similar to saying that the fastest car has no wheels, when you really mean that the fastest vehicle is a rocket. TAI is the most reliable and easiest to work with. It relies on atomic clock seconds at sea level. https://en.wikipedia.org/wiki/International_Atomic_Time However, it already h…

> That doesn't make a lot of sense, as UTC does have leap seconds. Pedantic much? Posting in technical forums is such a bother. People pick at any unimportant detail. Reworded just for you: The only reliable time stamp would be something like UTC but without leap seconds.

I am sorry. My intention was not to sound pedantic. I only wanted to point out that we are fortunate enough to already have what you describe.

I too wish we used TAI-based timestamps instead of Unix timestamps in a more widespread manner!

It is a bit silly that we cannot determine any duration involving a UTC time a couple of years in the future…

Re: The Fixing-JSON Conversation

#54

Earlier quoted context omitted.

> (Speaking of leap seconds, who thought seconds going from 0 - 60 rather than 0 - 59 was a good idea?) Who thought February going from 1-29 instead of 1-28 was a good idea? I don't understand why everyone seems to believe that the phenomena are so inherently different.

Because other months went to 30 or 31 already, so there was room for it in calendars and people never assumed months are always the same length. 60 seconds in a minute, OTOH, is a very strong assumption in many systems and people's minds.

> other months went to 30 or 31 already, so there was room for it in calendars and people never assumed months are always the same length

I really don't think this has much to do with it. It would predict no problems trying to add a November 31 to some year; I tend to make the opposite prediction.

Re: The Fixing-JSON Conversation

#55

Earlier quoted context omitted.

Because other months went to 30 or 31 already, so there was room for it in calendars and people never assumed months are always the same length. 60 seconds in a minute, OTOH, is a very strong assumption in many systems and people's minds.

> other months went to 30 or 31 already, so there was room for it in calendars and people never assumed months are always the same length I really don't think this has much to do with it. It would predict no problems trying to add a November 31 to some year; I tend to make the opposite prediction.

Remember February 30 1712? https://en.wikipedia.org/wiki/February_30#Swedish_calendar
Post reply on HN