Hacker News new | ask | show | jobs
by sly010 3470 days ago
> It doesn't translate cleanly to any kind of object structure in terms of code.

XML translates great to an object tree in many object oriented language.

  <foo bar="1">
    <yo />
    Hello
  </foo>


  new foo(new yo(), "hello", bar = 1)
Which is why it's so great to describe documents and static UIs.

I agree though that it's not a great choice for a REST API.

1 comments

But that's not concrete without another definition in place

    <foo yo="true">
      <bar>1</bar>
      <value>Hello</value>
    </foo>
Could represent the same object structure, for example. JSON is a pretty clean mapping to objects/properties/arrays, with less chance of confusion, or alternate interpretations.
It couldn't. That would mean a different thing and would be the abuse of what XML should be used for.

Whether something is inside an element or is a property of said element has important semantical meaning. But not just that, with XML you can implicitly represent ordering, whitespace and type information with much less boilerplate.

So the argument for JSON is basically boils down to: "Javascript has horrible type support and doesn't support OOP. JSON models that experience better."