I am designing an API for my webapp.
I was thinking to support only JSON responses (not XML) because more streamlined.
But I have just bumped to this XML:
It seems to me that the most exact correspondence between XML and JSON would need to represent an XML node as a triplet (i.e. array): [name, attributes, value], with name being a string, attributes an object with attribute names as keys and attribute values as (string) values, and value a string (for atomic values) or an array of such triplets.
By such mapping the JSON-equivalent of
Shopping
would be
[ "folders",
{},
[
[ "folder",
{ "id": "123",
"private": "0",
"archived": "0",
"order": "1"
},
"Shopping"
]
]
]
Actually the idea behind this mapping is that:
1) XML-JSON transformation be reversible. 2) The "sibling" relationship of sub-nodes be preserved
At the same time the distinction between attribute nodes and value nodes is explicit here.
Does it make sense? And does it justify the complexity overhead?