12 ms·
I don't quite see why you can't do the same with xml; maybe it needs some more typing, but it is expressing the same thing. <paws> <health status="ok"/>
by MichaelMoser123 10y ago
I don't quite see why you can't do the same with xml; maybe it needs some more typing, but it is expressing the same thing.
<paws>
<health status="ok"/>
<health status="ok"/>
<health status="ok"/>
<health status="ok"/>
</paws>
i thought that the main advantage of json was that it can be used as is (code as data) in javascript, but the problem here of course is that without a parser/validator one can inject tons of malicious code. If you are not on javascript then you can't do without a parser / in memory tree structure - and that's the same DOM model once again.
Json needs a bit less typing, now is that really such a significant difference? i think that adoption in matters of markup is more like a fashion - once people got the hang of it then it seems natural and goes without explanation.
i would say that there is one major difference - binary or text; as long as its text then it doesn't quite matter how you structure your markup; if you need your data to be of small size then you will have to compress it; however the parsing of a text tree will usually take more time than the serialization of a binary structure (by several factors);
Therefore you will use text markup where application speed is not very important, or where speed of development is more important than application performance, or you will use it for complicated configuration data (and your users will hate you because a name value format like ini files is easier to handle - well, mostly)
- lmm 10y ago> I don't quite see why you can't do the same with xml; maybe it needs some more typing, but it is expressing the same thing. It's not idiomatic though - the dog's paws aren't "healths". The point is that in XML each tag is expected to have a label and be an entity in its own right, whereas in JSON you expect each field to be an attribute.