CIDR Range Calculator
Work out a subnet: network, broadcast, host range and usable count.
Generate serde-ready Rust structs from a sample JSON document.
Needs serde = { version = "1", features = ["derive"] } in your Cargo.toml.
The rename attribute appears only where the snake_case name differs from the JSON key.
The JSON to Rust Struct converter writes serde-ready structs: a derive line with Serialize and Deserialize, snake_case fields, rename attributes only where the name actually differs, and Option<T> for keys that can be absent.
Paste a payload and get the structs, ready for serde: a derive line with Serialize and Deserialize, fields renamed to snake_case, and a serde rename attribute wherever the Rust name differs from the JSON key — and only where it differs, so the output stays readable.
Optional keys become Option<T>, which is how Rust represents a value that may not be there, and nested objects become their own structs declared alongside. Numbers are typed i64 or f64 depending on whether any decimal appears in the sample, and a value the sample cannot pin down falls back to serde_json::Value rather than guessing wrongly.
The serde attribute appears exactly where the snake_case Rust name differs from the JSON key, so the output stays readable.
A key missing anywhere in the sample becomes Option<T>, because serde returns an error rather than a default when a required field is absent.
Add Default, PartialEq or Clone to the derive line to match whatever your crate needs.
A field the sample cannot pin down becomes serde_json::Value rather than a wrong concrete type that fails at runtime.
Each nested object becomes its own named struct, so the whole payload is typed rather than half-typed.
An array of records gives better detection of optional fields.
Nested structs are named from the keys holding them.
Add or remove traits such as Default or PartialEq to match your crate.
Paste into a .rs file; add serde with the derive feature to Cargo.toml.
serde with the derive feature and serde_json: serde = { version = "1", features = ["derive"] } and serde_json = "1".
Because it is only needed when the snake_case Rust name differs from the JSON key. Adding it everywhere would be noise, so it appears exactly where it does something.
Because the key is missing or null somewhere in the sample. Without Option, serde returns an error on a payload that omits it.
Yes, and it is cleaner when every key follows one convention. Add #[serde(rename_all = "camelCase")] to the struct and delete the individual attributes.
What people who use the JSON to Rust Struct think of it. Reviews come from visitors and are posted as written.
No ratings yet
Yours would be the first.
0 reviews
Newest first
No reviews yet
Be the first to rate the JSON to Rust Struct. It takes half a minute and no account.
Write the first reviewWork out a subnet: network, broadcast, host range and usable count.
Turn text, SVG or a small file into a data: URI you can inline anywhere.
Build a docker-compose.yml with databases, caches and health checks.
Turn a .env file into JSON, with quotes, exports and comments handled.
Draft a GraphQL type definition from a sample JSON response.
Re-indent a SQL query into readable clauses, joins and conditions.
Pretty-print XML with clean indentation, or collapse it back to one line.
Build a Content-Security-Policy header directive by directive.