Live data from Hacker News

JSON or XML: Just Decide

mnot.net

11–20 of 44 posts

Re: JSON or XML: Just Decide

#11
post #8

JSON is great, but it is not nearly as flexible as XML, partly because of attributes. Also, because of it's JS heritage and compatibility, lots of common things are not representable in JSON. This is mostly because object keys MUST be strings. Examples: In [1]: from simplejson import dumps In [2]: dumps({1: 5, '1': 0}) Out[2]: '{"1": 0, "1": 5}' Derp, good luck figuring out what that is supposed to mean. In [3]: dump…

You're feigning outrage. It's a valid and well-documented design decision that keys in JSON are strings. If you want a language-specific serialization format based on JSON, come up with a dialect.

Being 'well documented' doesn't make it less of a pain.

Re: JSON or XML: Just Decide

#13

JSON is great, but it is not nearly as flexible as XML, partly because of attributes. Also, because of it's JS heritage and compatibility, lots of common things are not representable in JSON. This is mostly because object keys MUST be strings. Examples: In [1]: from simplejson import dumps In [2]: dumps({1: 5, '1': 0}) Out[2]: '{"1": 0, "1": 5}' Derp, good luck figuring out what that is supposed to mean. In [3]: dump…

I have spent equal amounts of time with XML and JSON. Here is what my experience told me: 1] XML is painful to write. 2] Languages don't natively support it. It always requires additional drivers/libraries. 3] Its non-trivial to store XML also. With the solutions that were out there we would always run into some requirements which the database didn't support, and had to done in the business logic. JSON databases (I u…

You can use MSGPack over HTTP just as easily as JSON. In fact, it performs better in most browsers.

Re: JSON or XML: Just Decide

#14
Or... they're designed for different purposes and not even competitors. XML is a markup language:

http://en.wikipedia.org/wiki/Markup_language

It was designed for documents. Try converting an HTML page to JSON. Try something as simple as:

   Hello World!  
  

The most common introductory program is called Hello, World .

Go on. If you think JSON wins, just do it, and post it below.

The problem was when people started mis-applying XML to send data structures, for RPC, and similar tasks. That's not what it was designed for. JSON is a cross-language way of specifying common data structures, and is very good at doing that.

Re: JSON or XML: Just Decide

#16

I like Turtle: dc:title "RDF/XML Syntax Specification (Revised)" ; ex:editor [ ex:fullname "Dave Beckett"; ex:homePage ] . It's only useful if you drank the RDF kool-aid (like I have), though.

You have good taste, since I invented Turtle. To keep this on topic, I've been using JSON for data web APIs since that's what it's best at. It sucks at: markup and graphs of course.

Re: JSON or XML: Just Decide

#17

JSON is great, but it is not nearly as flexible as XML, partly because of attributes. Also, because of it's JS heritage and compatibility, lots of common things are not representable in JSON. This is mostly because object keys MUST be strings. Examples: In [1]: from simplejson import dumps In [2]: dumps({1: 5, '1': 0}) Out[2]: '{"1": 0, "1": 5}' Derp, good luck figuring out what that is supposed to mean. In [3]: dump…

For comparison, what do the automatically generated XML versions of those JSON examples look like?

Re: JSON or XML: Just Decide

#18
post #14

Or... they're designed for different purposes and not even competitors. XML is a markup language: http://en.wikipedia.org/wiki/Markup_language It was designed for documents. Try converting an HTML page to JSON. Try something as simple as: Hello World! The most common introductory program is called Hello, World . Go on. If you think JSON wins, just do it, and post it below. The problem was when people started mis-appl…

I feel that the real distinction is whether you need to validate the contents against a grammar. The document/data distinction is fairly arbitrary. As far as I know, JSON has no equivalent of the DTD.
Post reply on HN