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
268 stars 26 forks source link

Add option to collect unknown properties #30

Closed evestera closed 2 years ago

evestera commented 3 years ago

Useful if you need to preserve all data on roundtrips. E.g. if you are fetching something, changing it and sending it back/somewhere else.

Jackson/Kotlin

    @JsonAnySetter
    @get:JsonAnyGetter
    val additionalFields: Map<String, Any> = mutableMapOf()

Rust/Serde

    #[serde(flatten)]
    additional_fields: HashMap<String, Value>,

Not relevant for TypeScript, but maybe for JSON Schema.

evestera commented 2 years ago

Implemented in 56e580cb5. Released in v0.7.0