feat: serde_json camelCase

This commit is contained in:
2020-12-29 23:35:28 +08:00
parent ffaba9fe48
commit 95917efa2d

View File

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