Skip to content

Releases: serde-rs/json

v0.9.8

21 Feb 18:22
v0.9.8
bbbef90
Compare
Choose a tag to compare
  • Implement serde::Deserializer for &serde_json::Value (#261)

    This can be convenient for deserializing from indexed content:

    let v = json!({ "m": { "serde": 1, "json": 100 } });
    
    let m: BTreeMap<String, u8> = Deserialize::deserialize(&v["m"])?;
  • Add an entry API to the serde_json::Map type, just like what BTreeMap has (#236)

    let mut map = serde_json::Map::new();
    
    map.entry("serde").or_insert(json!(12));
    
    match map.entry("serde") {
        Entry::Vacant(vacant) => {
            // can insert
        }
        Entry::Occupied(occupied) => {
            // can read, mutate, remove
        }
    }
    
    assert_eq!(map["serde"], 12);
  • Quit using voldemort types to parameterize the deserializer; this should make storing serde_json::Deserializer and StreamDeserializer in structs more convenient (#260)

v0.9.7

20 Feb 17:39
v0.9.7
864a00e
Compare
Choose a tag to compare
  • Expose serde_json::de::Read to simplify certain where clauses (#250)

    pub struct Client<R> {
        reader: StreamDeserializer<R, serde_json::Value>,
    }
    
    fn f<R>(c: Client<R>) where R: serde_json::de::Read { /* ... */ }
  • Some convenient new From impls (#253, thanks @killercup)

    • From for Value
    • From for Value
    • From<&str> for Value
    • From<Cow> for Value
    • From<Map<String, Value>> for Value
    • From<Vec> for Value where T: Into
    • From<&[T]> for Value where T: Clone + Into
    • FromIterator for Value where T: Into
  • Support deserializing strings as raw bytes (#257, thanks @bennofs)

v0.9.6

11 Feb 00:35
v0.9.6
426255b
Compare
Choose a tag to compare
  • Allow mutable square-bracket indexing into a serde_json::Value (#249)

    let mut data = json!({ "x": 0 });
    
    // replace an existing key
    data["x"] = json!(1);
    
    // insert a new key
    data["y"] = json!([false, false, false]);
    
    // replace an array value
    data["y"][0] = json!(true);
    
    // inserted a deeply nested key
    data["a"]["b"]["c"]["d"] = json!(true);

v0.9.5

03 Feb 15:52
v0.9.5
15827b4
Compare
Choose a tag to compare
  • Implement FromIterator and Extend for serde_json::Map (#240, thanks @Kroisse)

v0.9.4

01 Feb 23:58
v0.9.4
248df27
Compare
Choose a tag to compare
  • Remove clippy dependency to unblock the documentation build in docs.rs

v0.9.3

01 Feb 01:12
v0.9.3
6f8d5db
Compare
Choose a tag to compare
  • Impl Default for Value; the default Value is Value::Null (#226, thanks @killercup)
  • Fix a bug that could successfully deserialize enums from invalid JSON (#230, thanks @killercup)
  • Allow to_value to serialize maps with integer keys, matching the behavior of to_string (#231, thanks @killercup)
  • Impl PartialEq for Value to simplify comparisons with various primitive types (#235, thanks @imp)

v0.9.2

28 Jan 23:35
v0.9.2
a9b695d
Compare
Choose a tag to compare
  • Allow indexing into a serde_json::Map with square bracket syntax (#217, thanks @roblabla)

v0.9.1

26 Jan 07:25
v0.9.1
69632a6
Compare
Choose a tag to compare
  • Add "encoding" category and CI badge to crates.io

v0.9.0

25 Jan 21:14
v0.9.0
ce49f79
Compare
Choose a tag to compare

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.

v0.9.0-rc3

25 Jan 21:03
v0.9.0-rc3
7370630
Compare
Choose a tag to compare
v0.9.0-rc3 Pre-release
Pre-release
Release 0.9.0-rc3