5 releases (breaking)

0.16.0 Apr 1, 2025
0.15.0 Oct 24, 2024
0.14.0 Sep 22, 2024
0.13.0 Oct 26, 2023
0.1.9 Jul 10, 2020

#2954 in Parser implementations

Download history 192/week @ 2025-03-10 461/week @ 2025-03-17 111/week @ 2025-03-24 346/week @ 2025-03-31 335/week @ 2025-04-07 167/week @ 2025-04-14 56/week @ 2025-04-21 128/week @ 2025-04-28 125/week @ 2025-05-05 227/week @ 2025-05-12 182/week @ 2025-05-19 87/week @ 2025-05-26 158/week @ 2025-06-02 56/week @ 2025-06-09 132/week @ 2025-06-16 178/week @ 2025-06-23

527 downloads per month
Used in 8 crates (6 directly)

Apache-2.0/MIT

50KB
1.5K SLoC

simd-json-derive

Latest version documentation License

Derives for high performance JSON serialisation and deserialisation.

Usage


#[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:?}");
}

Supported Attributes

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 field

For structs:

  • rename_all = "camelCase" - renames all (not otherwise renamed) based on the rule, camelCase is currently supported
  • deny_unknown_fields - Errors if unknown fields are encountered

Dependencies

~2.3–3.5MB
~69K SLoC