#json-xml #xml #json #json-parser #structs #parser #json-key

schema_generator

This crate is a part of the ClimateForest project, which takes place between 01.03.2024–28.02.2027. It is funded by Interreg Aurora and supported by its contributors, including Metsäkeskus, Lapland University of Applied Sciences, Luke luonnonvarakeskus, Luleå Tekniska Universitet, Skoggstyrelsen, and SLU.

1 unstable release

new 0.2.8 Feb 11, 2025
0.2.7 Feb 9, 2025
0.2.3 Jan 18, 2025
0.1.9 Jan 18, 2025

#1667 in Parser implementations

Download history 433/week @ 2025-01-08 753/week @ 2025-01-15 592/week @ 2025-02-05

1,486 downloads per month

MIT license

1MB
743 lines

schema_generator

Features

  • create_structs_and_save_to_file: creates structs from an XML String and saves them to a file into the /src folder, making the structs ready for use in an application. When use_primitives is set to true, numeric fields will have type Number (e.g. i64 or f64). When it is set to false, all fields will have String type.
  • json_keys_to_lowercase: converts all keys in a serde_json value to lowercase. Additionally, it replaces all @ characters with __ to avoid unexpected behavior during JSON processing.
  • json_to_xml: converts JSON data into XML format. Attribute keys in the JSON are expected to be marked with __.

Usage

You can find integration tests and example usages of this crate in the Integration Test Repository.

Known bugs in JSON to XML conversion:

If the first nested element has attributes and the parent element also has attributes, the nested element will sometimes inherit the same prefix from the parent (and sometimes update to its own prefix as it's meant to). This is likely due to the recursive nature of the function.

Other mentions

Some namespaces are not included in the XML. The following namespace prefixes were manually added:

  • SpecialFeatures
  • SpecialFeature
  • TreeStrata

The field for IdentifierValue will be given type Option<String> even when use_primitives is set to true.

xlink:type attribute in gml:polygonProperty tags will show up as __type in Json

License

MIT License

Dependencies

~4.5–6.5MB
~117K SLoC