Clarify reasons for using `json` crate
dtolnay opened this issue · 3 comments
dtolnay commented
Here is your json
example from the readme rewritten using serde_json
. The differences are one type ascription ("let parsed: Value") and a slightly friendlier JSON literal syntax.
I think the readme should show an example that better plays to json
's strengths, or else omit this crate since serde and serde_json are already included.
#[macro_use]
extern crate serde_json;
use serde_json::Value;
fn main() {
let parsed: Value = serde_json::from_str(r#"
{
"code": 200,
"success": true,
"payload": {
"features": [
"awesome",
"easyAPI",
"lowLearningCurve"
]
}
}
"#).unwrap();
let instantiated = json!({
"code": 200,
"success": true,
"payload": {
"features": [
"awesome",
"easyAPI",
"lowLearningCurve"
]
}
});
assert_eq!(parsed, instantiated);
}
dtolnay commented
Even more relevant now with stable Serde.
brson commented
stdx uses serde_json now.