-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
50 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,21 @@ | ||
extern crate serde_json; | ||
|
||
use serde_json::Value; | ||
|
||
fn main() { | ||
// Some JSON input data as a &str. Maybe this comes from the user. | ||
let data = r#"{ | ||
"name": "John Doe", | ||
"age": 43, | ||
"phones": [ | ||
" 44 1234567", | ||
" 44 2345678" | ||
] | ||
}"#; | ||
|
||
// Parse the string of data into serde_json::Value. | ||
let v: Value = serde_json::from_str(data).unwrap(); | ||
|
||
// Access parts of the data by indexing with square brackets. | ||
println!("Please call {} at the number {}", v["name"], v["phones"][0]); | ||
} |