feat: serde_json camelCase
This commit is contained in:
@@ -40,6 +40,13 @@ struct TestStruct {
|
||||
timestamp: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct TestStruct2 {
|
||||
test_id: i32,
|
||||
test_name: String,
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let serialized = serde_json::to_string(&TestStruct{
|
||||
ty: TestEnum::TypeA,
|
||||
@@ -76,5 +83,11 @@ fn main() -> Result<()> {
|
||||
}
|
||||
println!("{}", john);
|
||||
|
||||
let test_struct2 = TestStruct2 {
|
||||
test_id: 1,
|
||||
test_name: "Hatter".into(),
|
||||
};
|
||||
println!("{}", serde_json::to_string(&test_struct2)?);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user