add mut
This commit is contained in:
@@ -39,7 +39,7 @@ fn main() -> Result<()> {
|
|||||||
let v: Value = serde_json::from_str(data)?;
|
let v: Value = serde_json::from_str(data)?;
|
||||||
println!("{}", v);
|
println!("{}", v);
|
||||||
|
|
||||||
let john = json!({
|
let mut john = json!({
|
||||||
"name": "John Doe",
|
"name": "John Doe",
|
||||||
"age": 43,
|
"age": 43,
|
||||||
"phones": [
|
"phones": [
|
||||||
@@ -47,6 +47,12 @@ fn main() -> Result<()> {
|
|||||||
"+44 2345678"
|
"+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);
|
println!("{}", john);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user