| Crates.io | simd-json-derive |
| lib.rs | simd-json-derive |
| version | 0.17.0 |
| created_at | 2020-06-17 07:33:39.622572+00 |
| updated_at | 2025-09-11 10:24:22.277568+00 |
| description | derives for simd-json |
| homepage | https://docs.rs/simd-json-derive |
| repository | https://github.com/simd-lite/simd-json-derive/ |
| max_upload_size | |
| id | 254847 |
| size | 122,601 |
Derives for high performance JSON serialisation and deserialisation.
#[derive(Serialize, Deserialize, Debug)]
#[simd_json(deny_unknown_fields, rename_all = "camelCase")]
struct MyStruct {
first_field: String,
#[simd_json(rename = "foo")]
second_field: Option<usize>
}
fn main -> Result<(), simd_json::Error> {
let my_struct = MyStruct {
first_field: "i am first".to_string(),
second_field: None
}
println!("Before: {my_struct:?}");
let mut json_string = my_struct.json_string()?;
let deserialized = MyStruct::from_str(json_string.as_mut_str())?;
println!("After: {deserialized:?}");
}
Attributes are supported for both #[simd_json(...)] and for compatibilty also for #[serde(...)] and follow the same naming conventions as serde.
For fields:
rename = "new_name" - renames a fieldFor structs:
rename_all = "camelCase" - renames all (not otherwise renamed) based on the rule, camelCase is currently supporteddeny_unknown_fields - Errors if unknown fields are encountered