CLI for generation of type definitions for Rust, Kotlin, TypeScript and JSON Schema from JSON
Note: There is also a web interface, and for Rust types there is also a procedural macro interface to this code, which uses the same underlying algorithm and code generation. See the repository for details.
Installation
# installed binary is called json_typegen
# make sure ~/.cargo/bin is on your PATH
Usage
To generate the Rust type Point
in point.rs
from a local sample, run:
Note: The output file (e.g. src/point.rs
) will be overwritten if it exists.
For an online sample, run:
The generated code assumes the availability of serde
and serde_derive
, so
make sure your Cargo.toml
contains something like:
[]
= "1.0"
= "1.0"
# Not required, but you probably also want:
= "1.0"
Options and configurations
For help with the CLI itself run json_typegen -h
. To configure visibility and
other options see the general configuration documentation.
Other languages
The CLI currently has rudimentary support for Kotlin, TypeScript and JSON Schema. Contributions for these and additions of others are welcome.