News for hackers. Stuff that matters.
Re:RESTful considered harmful by josephscott on Friday July 24, 2015 @11:11AM (#9942514)
<blockquote> Of course JSON has one (literally, one) tremendous advantage - it's human readable. </blockquote>

I was surprised he didn't mention ease of use inside JavaScript.

Re:RESTful considered harmful by jpollock on Friday July 24, 2015 @11:18AM (#9942554)
You're not supposed to eval the strings, that way leads to xss. Since you're supposed to parse it no matter what, there's no difference between JSON and any other format.
Re:RESTful considered harmful by bwy on Friday July 24, 2015 @11:24AM (#9942595)
Umm. I have no clue how you can say this. In JavaScript, JSON is unquestionably the easiest format to use.

It may or may not be the same to parse, say, JSON and XML.

But how is

xmlDoc=new DOMParser().parseFromString(booksXml);

newatt=xmlDoc.createAttribute("edition");

newatt.nodeValue="first";

x=xmlDoc.getElementsByTagName("title");

x[0].setAttributeNode(newatt);

as easy to use as

JSON.parse(booksJson).title.edition = 'first'

?

Re:RESTful considered harmful by xrstf on Friday July 24, 2015 @11:26AM (#9942612)
Modern browsers ship with `JSON.parse()`, but not with ProtocolBuffer.parse(), Thrift.parse() or BSON.parse().

This advantage has nothing to do with eval(), but rather that JSON is pretty much built-in everywhere nowadays.

Re:RESTful considered harmful by Drakim on Friday July 24, 2015 @11:23AM (#9942583)
Not true. While you should indeed not eval the string, once you have properly parsed it, you get a structured collection of objects and arrays that is very regular JavaScript structures. XML cannot offer the same, you get some much more abstract representation can easily be "wrong" if you don't follow the format as you extend it with more values, objects and arrays.
Re:RESTful considered harmful by jflatow on Friday July 24, 2015 @11:23AM (#9942592)
Not really, browsers still provide native JSON parsing ability - which is faster (and easier to implement) than most other parsing you would write inside JavaScript.
Re:RESTful considered harmful by mgr86 on Friday July 24, 2015 @11:23AM (#9942587)
I haven't read the article yet, and while I prefer to work with JSON most of the time XML is much more human readable. And working in publishing we have a lot of XML floating around.
Re:RESTful considered harmful by cableshaft on Friday July 24, 2015 @11:37AM (#9942700)
I agree. When I am creating raw data to be consumed later (like for a personal project or something), I often find myself typing it up in XML and then using an XML -> JSON converter to change it to JSON for my actual code.

I can just think in XML easier than remembering "Okay, so there's a bracket here, and a curly brace here, or is it curly brace and bracket? Do I need to include a key value here or not? Oh crap, I overlooked a comma again." I constantly have to send my JSON through lint, where I don't ever have to worry about that with XML.