Rust
Rust
JSON Insert Empty Array or Object
See more JSON Examples
Demonstrates how to use the UpdateNewArray and UpdateNewObject methods to insert an empty array or object.Note: The UpdateNewArray an UpdateNewObject methods were introduced in Chilkat v9.5.0.75.
Chilkat Rust Downloads
let json = chilkat::JsonObject::new();
// The following code builds the following JSON, which contains both an empty array and empty object:
// {
// "abc": {
// "xyz": [
// {
// "Name": "myName",
// "Description": "description",
// "ScheduleDefinition": "schedule definition",
// "ExceptionScheduleDefinition": "",
// "Attribute": [
// ],
// "SomeEmptyObject": {},
// "token": "token"
// }
// ]
// }
// }
let _ = json.update_string("abc.xyz[0].Name", "myName");
let _ = json.update_string("abc.xyz[0].Description", "description");
let _ = json.update_string("abc.xyz[0].ScheduleDefinition", "schedule definition");
let _ = json.update_string("abc.xyz[0].ExceptionScheduleDefinition", "");
let _ = json.update_new_array("abc.xyz[0].Attribute");
let _ = json.update_new_object("abc.xyz[0].SomeEmptyObject");
let _ = json.update_string("abc.xyz[0].token", "token");
json.set_emit_compact(false);
println!("{}", json.emit().unwrap_or_default());