pub fn deserialize_struct_case_insensitive<'de, T, D>(
deserializer: D,
) -> Result<T, D::Error>where
T: DeserializeOwned,
D: Deserializer<'de>,
Expand description
Deserializes a struct without checking for the fields case sensititivity.
§Notes
- The following deserializer is incompatible with serde’s one. If you wish
to use
serde(rename)
, there is a high risk it won’t work. Please see https://github.com/vityafx/serde-aux/issues/8 for further information.
§Example:
use serde_aux::prelude::*;
#[derive(serde::Deserialize, Debug)]
struct AnotherStruct {
aaa: String,
}
#[derive(serde::Deserialize, Debug)]
struct MyStruct {
#[serde(deserialize_with = "deserialize_struct_case_insensitive")]
another_struct: AnotherStruct,
}
let s = r#"{ "another_struct": { "AaA": "Test example" } }"#;
let a: MyStruct = serde_json::from_str(s).unwrap();
assert_eq!(a.another_struct.aaa, "Test example");