News for hackers. Stuff that matters.
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.