Live data from Hacker News

ECMA-404: The JSON Data Interchange Format [pdf]

ecma-international.org

61–70 of 199 posts

Re: ECMA-404: The JSON Data Interchange Format [pdf]

#61

Why can the solidus (/) be escaped?

Oh, god - apparently, it's to support IE5.5 and to allow "" to be embedded in a "" pair and not be interpreted as closing the script. I wish I hadn't asked, and I wish I hadn't then gone and found out ...

Re: ECMA-404: The JSON Data Interchange Format [pdf]

#62

Earlier quoted context omitted.

Trailing commas would make the problem worse! If you allow trailing commas then you would break json parsing in all old version of IE. The unicode line ending problem is more subtle. I have seen people write code like (mix javascript and some templating): var prefs = ; ... The above code looks okay, but if the json is just spec conforming, then you are exposed to a potential XSS attack. Most people that write json en…

> you would break json parsing in all old version of IE Why do people still care about old versions of IE?

IE10, IE11 in non-standards mode also don't accept trailing commas. I don't care if you accept trailing commas, but dear god, never emit them.

Re: ECMA-404: The JSON Data Interchange Format [pdf]

#63
post #58

Earlier quoted context omitted.

The slash and the solidus are two separate entities. I am not aware of any use of the actual solidus being used for escaping.

I am talking about BACKslash (REVERSE solidus). This says they are the same: http://en.wikipedia.org/wiki/Backslash

Interesting. It says they're the same thing, but then the two characters listed on the page (the regular backslash and the Unicode variant) are rendered noticeably differently.

I can't imagine why they changed the name, given that the forward slash and the solidus are not interchangeable. http://www.fileformat.info/info/unicode/char/5c/index.htm

Re: ECMA-404: The JSON Data Interchange Format [pdf]

#64
post #8

My faint hopes for trailing comma support are now crushed.

I was crossing my fingers for that too. I create JSON files a lot. It's annoying when I'm _reordering_ elements separated by newlines. It's annoying when I'm generating JSON files and I have to code in a special case to skip the comma. It breaks the consistency that I just desire as a programmer.

Re: ECMA-404: The JSON Data Interchange Format [pdf]

#65
post #55

Earlier quoted context omitted.

The ability to be lazy.

Doesn't seem like a good reason for a spec. Laziness is partly why Javascript as a language is so messed up.

If I could down-vote this lazy, drive-by, language bashing I would. Back up 'so messed up' or keep comments like this to yourself, they don't help the discussion.

Re: ECMA-404: The JSON Data Interchange Format [pdf]

#66
Several comments mention the "Software shall be used for Good, not Evil" licensing issue in the JSON code from json.org.

The original json.js file from json.org had this copyright and license:

  Copyright (c) 2005 JSON.org
  
  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:
  
  The Software shall be used for Good, not Evil.
  
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  SOFTWARE.
http://web.archive.org/web/20060226161035/http://www.json.or...

This was a standard MIT license with one change:

"This license uses the Expat [MIT] license as a base, but adds a clause mandating: “The Software shall be used for Good, not Evil.” This is a restriction on usage and thus conflicts with freedom 0. The restriction might be unenforcible [sic], but we cannot presume that. Thus, the license is nonfree."

http://www.gnu.org/licenses/license-list.html#JSON

However, the current versions of json.js and json2.js on GitHub contain only this public domain dedication and disclaimer:

  Public Domain.

  NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
https://github.com/douglascrockford/JSON-js/blob/master/json...

So it's no longer an issue. You can feel free to use json2.js for good or evil.

Re: ECMA-404: The JSON Data Interchange Format [pdf]

#68

Earlier quoted context omitted.

That's just a license for software available on json.org, so no impact at all.

Where is it on json.org? I can't seem to find it.

The current versions of json.js and json2.js do not have the "evil" license clause. See my other comment:

https://news.ycombinator.com/item?id=6534318

Re: ECMA-404: The JSON Data Interchange Format [pdf]

#69

Earlier quoted context omitted.

For large code bases, you don't break git blame by adding in new arguments. And it's one less thing to think about when editing your code: always add a comma, never worry about errors because you need to add a comma to the line above.

This is why you prepend the comma before every succeeding item in a list or map.

This is what I do, but it basically just has the effect of making the first item special instead of the last. That's usually better in practice, though.

Re: ECMA-404: The JSON Data Interchange Format [pdf]

#70
post #55

Earlier quoted context omitted.

Doesn't seem like a good reason for a spec. Laziness is partly why Javascript as a language is so messed up.

If I could down-vote this lazy, drive-by, language bashing I would. Back up 'so messed up' or keep comments like this to yourself, they don't help the discussion.

LOL! Obviously I struck a nerve. I thought it was obvious to everyone the problems of Javascript as a language. For laziness, how about weak typing and defining a class using a function. Plenty more examples, but you can do your own research if you are curious. BTW I like and use Javascript, but it is still a crap language.
Post reply on HN