Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify reasons for using json crate #21

Closed
dtolnay opened this issue Jan 29, 2017 · 3 comments
Closed

Clarify reasons for using json crate #21

dtolnay opened this issue Jan 29, 2017 · 3 comments

Comments

@dtolnay
Copy link
Collaborator

dtolnay commented Jan 29, 2017

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);
}
@brson
Copy link
Owner

brson commented Feb 1, 2017

Thanks for the suggestion @dtolnay !

@dtolnay
Copy link
Collaborator Author

dtolnay commented Apr 22, 2017

Even more relevant now with stable Serde.

@brson
Copy link
Owner

brson commented Jun 8, 2017

stdx uses serde_json now.

@brson brson closed this as completed Jun 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants