Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kitagry/json-rs
practice rust
https://github.com/kitagry/json-rs
Last synced: 15 days ago
JSON representation
practice rust
- Host: GitHub
- URL: https://github.com/kitagry/json-rs
- Owner: kitagry
- Created: 2020-05-02T13:30:28.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-05-04T12:53:31.000Z (over 4 years ago)
- Last Synced: 2024-12-15T14:43:51.402Z (19 days ago)
- Language: Rust
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# json-rs
practice rust.
## Example
value which will be parsed from json is as followings.
```rust
#[derive(Debug, Clone, PartialEq)]
pub enum Value {
Null,
Bool(bool),
Number(Number),
String(String),
Array(Vec),
Object(HashMap),
}
```And, the followings is example.
```rust
use json_rs::{from_str, Value};fn main() {
let data = r#"
{
"name": "John Doe",
"age": 43,
"phones": [
"+81 4444",
"+81 4444"
]
}
"#;let v: Value = from_str(data.to_string()).unwrap_or(Value::Null);
println!("Please call {} at the number {}", v["name"], v["phones"][0]);
}
```## License
MIT
## Author
Ryo Kitagawa