{"repo":"evestera/json_typegen","free":true,"listed":false,"github":"https://github.com/evestera/json_typegen","clone":"git clone https://github.com/evestera/json_typegen.git","description":"Tools and libraries to create types for Rust, Kotlin, TypeScript and Python from JSON samples","language":"Rust","stars":319,"topics":["rust","json","code-generation"],"license":"Apache-2.0","category":"dev-tools","readme_excerpt":"json typegen - Types from JSON samples json typegen is a collection of tools for generating types from JSON samples for Rust, Kotlin and TypeScript. I.e. you give it some JSON, and it gives you the type definitions necessary to use that JSON in a program. There are three interfaces to this code generation logic: - Rust procedural macro - Command line interface - Web interface Procedural macro In Rust the code generation can be used straight from the program you are making, with a procedural macro. For those familiar with [F#], the procedural macro json typegen! works as a [type provider] for JSON in Rust. It was inspired by and uses the same kind of inference algorithm as [F# Data]. [serde]: https://serde.rs/ [F# Data]: http://fsprojects.github.io/FSharp.Data/ [F#]: http://fsharp.org/ [type provider]: https://docs.microsoft.com/en-us/dotnet/fsharp/tutorials/type-providers/ As an example, the below code generates the type Point based on an inline sample. The following crate dependencies are necessary for this example to work: The sample json can also come from local or remote files: The code generation can also be customized: For the details on configuration, see the relevant documentation. Conditional compilation To avoid doing a HTTP request per sample used for every build you can use conditional compilation to only check against remote samples when desired: And in Cargo.toml: You can then verify that remote samples match your expectations in e.g. CI builds as follows: Comma","default_branch":null,"files":null,"tree":[],"storefront":"/r/evestera","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/evestera/json_typegen/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}