3 ms·
Discussions about XML and JSON often remind me of this comment on HN: https://news.ycombinator.com/item?id=5702868 https://news.ycombinator.com/item?id=5702868
by erlehmann_ 10y ago
Discussions about XML and JSON often remind me of this comment on HN: https://news.ycombinator.com/item?id=5702868 https://news.ycombinator.com/item?id=5702868
Partial quote:
> XML can certainly be shorter than JSON and often is, and repeated tags are the best showcase for it:
<user id="abc">
<phoneNo type="home">123456789</phoneNo>
<phoneNo type="work">321654987</phoneNo>
</user>
> This turns into this beautiful JSON:
[
"users": [
{
"id": "abc",
"phoneNos": [
{ "type": "home", "value": "123456789" },
{ "type": "work", "value": "321654987" }
]
}
]
]
- lmm 10y agoNot a fair comparison since the JSON case includes the outer list as well. And whenever I've seen the equivalent of this in a real-world XML format it would use a <phoneNos> tag to group the phone numbers together.
- erlehmann_ 10y agoYou probably have not looked too closely at real-world XML. • Many XHTML and SVG elements can occur without dedicated wrapper elements. • In Atom feeds, <author>, <category>, <contributor>, <link> elements can occur multiple times without a dedicated wrapper element. • In XSPF playlists, <link>, <meta>, <extension>, <location>, <identifier> elements can occur multiple times without a dedicated wrapper element.