Rust
Rust
JSON PathPrefix Example
Demonstrates the JSON object'sPathPrefix property.
Chilkat Rust Downloads
let json = chilkat::JsonObject::new();
json.set_path_prefix("company.billing.");
let _ = json.update_string("company_name", "TechNova Solutions Inc.");
let _ = json.update_string("address_line_1", "123 Innovation Drive");
let _ = json.update_string("address_line_2", "Suite 450");
let _ = json.update_string("city", "Seattle");
let _ = json.update_string("state_province", "WA");
let _ = json.update_string("postal_code", "98101");
let _ = json.update_string("country", "USA");
json.set_emit_compact(false);
println!("{}", json.emit().unwrap_or_default());
// Result:
// {
// "company": {
// "billing": {
// "company_name": "TechNova Solutions Inc.",
// "address_line_1": "123 Innovation Drive",
// "address_line_2": "Suite 450",
// "city": "Seattle",
// "state_province": "WA",
// "postal_code": "98101",
// "country": "USA"
// }
// }
// }
let city = json.string_of("city").unwrap_or_default();
println!("city = {}", city);