evestera / json_typegen

Tools and libraries to create types for Rust, Kotlin, TypeScript and Python from JSON samples
https://typegen.vestera.as
Apache License 2.0
273 stars 26 forks source link

Output types in the order they appear in the sample #2

Closed evestera closed 7 years ago

evestera commented 7 years ago

Generating the type zero from the following sample:

{
  "one": {
    "two": {},
    "three": {}
  },
  "four": {}
}

Currently generates types in this order, that we then reverse.

#[derive(Default, Debug, Clone, Serialize, Deserialize)]
struct Two {}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
struct Three {}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
struct One {
    two: Two,
    three: Three,
}

#[derive(Default, Debug, Clone, Serialize, Deserialize)]
struct Four {}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
struct Zero {
    one: One,
    four: Four,
}

Ideally, types should be output in the order they appear in the sample.

evestera commented 7 years ago

Fixed by 2a2d2e2f8580948fddbc78ba1aee22ea58be3dc1