| Crates.io | yojson-rs |
| lib.rs | yojson-rs |
| version | 0.1.2 |
| created_at | 2021-01-20 14:55:26.682969+00 |
| updated_at | 2021-04-22 16:48:01.994414+00 |
| description | A parser for Yojson format(https://mjambon.github.io/mjambon2016/yojson.html). |
| homepage | |
| repository | https://github.com/puripuri2100/yojson-rs |
| max_upload_size | |
| id | 344426 |
| size | 30,120 |
This library parses JSON data (yojson format) into a nested Rust tree data structure.
A value in Yojson is represented with the Value enum in this crate:
pub enum Value {
Null,
Bool(bool),
Integer(i64),
Float(f64),
String(String),
Assoc(Assoc),
Array(Array),
Tuple(Vec<Value>),
Variant(Variant),
}
The Yojson format is an extension of the JSON format. See "Yojson format document" for more information.
(1.23, 4.56).<"Foo">.<"Bar": 123>.[A-Za-z][A-Za-z_0-9]*: { x: <Foo>, "#y": <Bar2> }./* multiline comment */ and // end-of-line comment.[ Infinity, -Infinity, NaN ].Parse JSON data.
use yojson_rs;
fn main () {
let json = r#"
{
x : 123,
y : {
"y1" : "abc\ndef\u0021",
"y2" : [null, 123.45, (12, "y3")]
},
z : NaN
}
"#;
assert!(yojson_rs::parser::parse(json).is_ok());
}
A data structure can be converted to a JSON string by to_string.
use yojson_rs;
fn main() {
let json_str = r#"
{
x : 123,
y : {
"y1" : "abc\ndef\u0021",
"y2" : [null, 123.45, (12, "y3")]
},
z : NaN
}
"#;
let json = yojson_rs::parser::parse(json_str).unwrap();
println!("{}", yojson_rs::to_string(json));
}
(c) 2021 Naoki Kaneko (a.k.a. "puripuri2100")