|
@ -1,7 +1,6 @@ |
|
|
use serde_json::{Value}; |
|
|
use serde_json::{Value}; |
|
|
|
|
|
|
|
|
fn json_str() -> String { |
|
|
const JSON_STR: &str = r#"{ |
|
|
let json = r#"{ |
|
|
|
|
|
"demo": "key_1", |
|
|
"demo": "key_1", |
|
|
"author": "dnomd343", |
|
|
"author": "dnomd343", |
|
|
"test": [ |
|
|
"test": [ |
|
@ -10,13 +9,13 @@ fn json_str() -> String { |
|
|
"345" |
|
|
"345" |
|
|
] |
|
|
] |
|
|
}"#; |
|
|
}"#; |
|
|
return String::from(json); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn main() { |
|
|
fn main() { |
|
|
let raw = json_str(); |
|
|
println!("JSON raw content ->\n{}", JSON_STR); |
|
|
println!("JSON raw content ->\n{}", raw); |
|
|
|
|
|
|
|
|
let data: Value = serde_json::from_str(JSON_STR).unwrap(); |
|
|
|
|
|
println!("{:#?}", data); |
|
|
|
|
|
|
|
|
let parsed: Value = serde_json::from_str(&raw[..]).unwrap(); |
|
|
let ret = serde_json::to_string(&data).unwrap(); |
|
|
println!("Author -> {}", parsed["author"]); |
|
|
println!("JSON output ->\n{}", ret); |
|
|
} |
|
|
} |
|
|