add mut
This commit is contained in:
@@ -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(())
|
||||
|
||||
Reference in New Issue
Block a user