Skip to content

Releases: serde-rs/json

v1.0.5

29 Oct 04:57
v1.0.5
8b3f37a
Compare
Choose a tag to compare
  • Documentation improvements

v1.0.4

15 Oct 17:53
v1.0.4
bea035b
Compare
Choose a tag to compare
  • Improve error message for an array or object containing a trailing comma, which is not allowed in JSON (#353, thanks @fmoor)

v1.0.3

04 Sep 20:45
v1.0.3
764e960
Compare
Choose a tag to compare
  • Performance improvement for parsing ignored data (#174)
  • Implement PartialEq<bool> for Value (#338, thanks @foriequal0)

v1.0.2

08 May 23:12
v1.0.2
4e33d77
Compare
Choose a tag to compare

v1.0.1

28 Apr 00:12
v1.0.1
8202c68
Compare
Choose a tag to compare
  • Fix deserialization of maps with non-string keys (#311)

    For example {"1":"one"} can be serialized and deserialized as BTreeMap<i32, String>.

v1.0.0

20 Apr 15:53
v1.0.0
d45ddf7
Compare
Choose a tag to compare

First of all, go read the Serde 1.0.0 release notes!


Zero-copy deserialization

This release supports Serde 1.0's zero-copy deserialization feature. This allows borrowed data to be deserialized efficiently and safely.

#[macro_use]
extern crate serde_derive;

extern crate serde;
extern crate serde_json;

#[derive(Deserialize, Debug)]
struct User<'a> {
    fingerprint: &'a str,
    location: &'a str,
}

fn main() {
    let j = "{
               \"fingerprint\": \"0xF9BA143B95FF6D82\",
               \"location\": \"Menlo Park, CA\"
             }";

    let u: User = serde_json::from_str(j).unwrap();
    println!("{:#?}", u);
}

Breaking changes

  • The StreamDeserializer now only supports arrays and objects.

    Previously it supported any JSON value, leading to confusing behavior like truetrue being deserialized successfully as two boolean values.

  • The ToJson trait has been removed.

    Please use serde_json::to_value instead. See #294 for some justification.

  • Support for deserializing from Iterator<Item = io::Result<u8>> removed.

    Please use serde_json::from_reader instead.

  • The Formatter trait methods now return io::Result.

    Previously they returned serde_json::Result. There should be no reason for a formatter to fail other than IO.

  • The Formatter::write_string_fragment method now receives &str.

    Previously the method received &[u8] but it was always valid UTF-8.

  • Conversion From<io::Error> for serde_json::Error removed.

    The serde_json::Error type is intended to be constructed by serde_json, not by your code.

  • The writer argument is passed by value to serde_json::to_writer.

    The standard library provides impl<'a, W: Write + ?Sized> Write for &'a mut W so passing a &mut W will continue to work.

v0.9.10

09 Apr 15:18
v0.9.10
34196d6
Compare
Choose a tag to compare
  • Extend the serde_json::Error API with accessors for the line, column, and category of errors (#278)
  • Pretty-print serde_json::Value when formatted with {:#} (#280, thanks @imp)

v0.9.9

06 Mar 01:57
v0.9.9
ea4791d
Compare
Choose a tag to compare
  • Allow dynamically generated strings to be serialized with zero allocations using Serde 0.9.11's new collect_str (#267, thanks @nox)

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)