| ▲ | dgrunwald 11 hours ago | |
> Furthermore parsing JSON or YAML gives you the basic data types like lists and dictionaries. Parsing XML gives you an AST that requires a lot more effort to turn into data in your domain. More precisely: in XML, elements (nodes) are named/labeled. ("node-labeled graph") In JSON, keys (edges) are named. ("edge-labeled graph") In programming, we need names for the fields in our structures (edges between objects), so JSON is a much better match than XML (which needs contortions to handle this use case -- e.g. by having nesting levels alternate between element=node and element=edge). Only in some object-oriented cases (which derived class should the deserializer construct?) do you care about node labels -- but usually that's in addition to edge labels, so a "_type" key in JSON is still easier than XML. | ||
| ▲ | conartist6 11 hours ago | parent | next [-] | |
CSTML gets the best of both worlds https://docs.bablr.org/guides/cstml | ||
| ▲ | gf000 10 hours ago | parent | prev [-] | |
Well, "easier" may well be "one less dimension to encode data" in this case. Sure, this gives quite a few variations on how to serialize some data. But it's not like json's simpler approach would make data serialization universal, there are many different ways to encode the same thing. | ||