Hello! When I use the sqlx::query_as!
macro I get compile time type validation. Is there anything that lets me do that with a JSON file? Specifically I want a crate that generates/validates a type with a JSON file. I don't want a website to generate it
You can put calls to serde_json
in a proc-macro.
You should check out json_shema. It's all about validating json for correctness. It's dynamic in that you give it json and then it tells you if it conforms to the schema, but you'll just need to run it at build time. Perhaps a proc macro or maybe just a regular build step before compiling.
I think I came across a json_schema crate... Ah this might be the one: crates.io: Rust Package Registry
There are a bunch of crates doing similar things and related things like generating schemas, or generating struct definitions from a schema.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.