cargo serde_json 0.9.0

latest releases: 1.0.132, 1.0.131, 1.0.130...
7 years ago

This release features a redesigned serde_json::Value enum that better represents the loosely-typed reality of common JSON workflows in Rust. Don't despair - strongly typed Serde serialization and deserialization is still supported of course.

enum Value {
    Null,
    Bool(bool),
    Number(Number),
    String(String),
    Array(Vec<Value>),
    Object(Map<String, Value>),
}

See the documentation for example code, including some examples of indexing into a serde_json::Value in a concise way: jv["address"]["city"].

This release adds a json! macro for building serde_json::Value objects in your program from a very natural JSON syntax.

// The type of `value` is serde_json::Value
let value = json!({
    "code": 200,
    "success": true,
    "payload": {
        "features": [
            "serde",
            "json"
        ]
    }
});

Any expression can be included in the serde_json::Value that you build. This works as long as the type of the expression implements Serde's Serialize trait.

let code = 200;
let features = vec!["serde", "json"];

let value = json!({
   "code": code,
   "success": code == 200,
   "payload": {
       features[0]: features[1]
   }
});

Please read also the Serde 0.9.0 release notes.

Don't miss a new serde_json release

NewReleases is sending notifications on new releases.