JSON Example: Fix all types
Apparently, in the Analytics JSON example, except for Frame/Object/Appearance/Color/ColorCluster/Color/Weight, all attribute values have been encoded as strings instead of their JSON types number or the boolean values. This pull request fixes that. I have double-checked the data types against the respective XML/XSD schema files.
As far as I know we were targeting a simple xml to json conversion logic and the example is as per the conversion table defined, if proper type conversion is required then the xml to json convertor should have prior knowledge of xml schema.
I agree with Sujith on this. I think all values should be strings. Otherwise the translator needs deep knowledge about the schema. If all values are strings the translation is very easy to implement.
I do not agree that loosing all type information is a good idea. If you are actually using code generators (based e.g. on a JSON Schema) for validation and parsing for typed languages like https://quicktype.io/, the automatic validation and conversion to a specific type will not take place and would have to be done manually (and very error-pronely) afterwards.
In general, all validation of the JSON output via a JSON schema will not be very thorough (well, basically not useful at all) when types are non-existent.
In my opinion "native" usability, expressiveness and validatability and of the JSON data structures should be considered more important than apparent "ease" of a xml/json conversion, especially considering that JSON data structures will probably be used where XML data structures are not.
Any updates on my points?
Any updates on my points?
Agree that preserving type in json is very useful in many use cases, but the example is simply following the conversion table defined in "5.4.3 JSON payload format" section. It would be better to update this section, either by updating the table or by adding a special note on preserving data types.
See also PR #246 as a per-requisit.