3 ms·
Parsing XML is just grammar like JSON is ... that is not more or less difficult. JavaScript just has a built-in JSON Parser (which translate JSON into JavaScrip
by oaiey 5y ago
Parsing XML is just grammar like JSON is ... that is not more or less difficult. JavaScript just has a built-in JSON Parser (which translate JSON into JavaScript object).
As a consequence, JSON in JavaScript is super easy. Using XML is medium-hard.
In .NET using XML or JSON is easy (not super easy).
In C++ using XML or JSON is medium-hard.
Do not know the state of the art for Go, Rust, Java, ...
As a consequence, JSON is - from a JavaScript developer perspective - the holy grail. From a .NET/Java/C++ developer perspective it is just another format.
- radomir_cernoch 5y agoIn can't agree more. In Java, there's the JAXB ”parser“ which translates an XML schema into (mostly) straightforward classes. Correct initial setup is the only hard part.
- diroussel 5y agoThe key difference is that there are no options when you parse json. You just parse it and get some lists and maps back. In XML you have to decide if you want DTD or schema enabled (which could provide default values, and could be a security risk) and where abs how you resolve the DTDs from etc. Do you resolve references? And many option options. So JSON benefits not just from a simpler structure, but also from less optionality.
- oaiey 5y agoYou do not pull schemas dynamically. Schemalocation beyond editors is a pure theory thing. It is not default, it cannot be fast. Any serious developer has the schemas as files in their code when checking the data for compliance. Basically, in a static typed language you decide for schema checking or not - like for Json -, serializing in structures or access in an API - like for Json. It is just that JavaScript maps json directly in their dynamic object, array and native types. For xml that is an mismatch. For static languages both are an mismatch.
- staticassertion 5y ago> Parsing XML is just grammar like JSON is ... that is not more or less difficult. My understanding is that that's not the case. XML parsers are Pull or SAX based and it's weird as fuck. You can abstract that out, but parser complexity isn't something to sneeze out. For one thing, parsing XML is notoriously dangerous - tons of vulns both at a design and memory management level.