This commit is contained in:
2020-01-19 00:44:09 +08:00
parent dc65673cea
commit 08ec72f568

View File

@@ -39,7 +39,7 @@ fn main() -> Result<()> {
let v: Value = serde_json::from_str(data)?;
println!("{}", v);
let john = json!({
let mut john = json!({
"name": "John Doe",
"age": 43,
"phones": [
@@ -47,6 +47,12 @@ fn main() -> Result<()> {
"+44 2345678"
]
});
println!("{}", &john);
if let Option::Some(ref mut m) = john.as_object_mut() {
m.insert("test".into(), Value::Bool(true));
m.insert("test2".into(), Value::String("hello world".into()));
}
println!("{}", john);
Ok(())