Serialize fields as camelCase
use serde::Serialize;
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
struct Person {
first_name: String,
last_name: String,
}
fn main() {
let person = Person {
first_name: "Graydon".to_string(),
last_name: "Hoare".to_string(),
};
let json = serde_json::to_string_pretty(&person).unwrap();
// Prints:
//
// {
// "firstName": "Graydon",
// "lastName": "Hoare"
// }
println!("{}", json);
}