Skip to content

Releases: serde-rs/json

v1.0.17

01 May 20:16
v1.0.17
e0a350f
Compare
Choose a tag to compare
  • Consistent meaning of serde_json::Value equality whether or not "preserve_order" feature is enabled (#438, thanks @Diggsey)

v1.0.16

21 Apr 22:18
v1.0.16
5dcf09d
Compare
Choose a tag to compare
  • Add values_mut() iterator for serde_json::Map (#437)

v1.0.15

17 Apr 18:55
v1.0.15
7bcb7c7
Compare
Choose a tag to compare
  • Make treatment of deserializer hints by serde_json::from_value consistent with serde_json::from_str

v1.0.14

15 Apr 03:25
v1.0.14
aeed62d
Compare
Choose a tag to compare
  • Clearer Debug representation of serde_json::Error (#410)

v1.0.13

21 Mar 19:15
v1.0.13
8c5d5e4
Compare
Choose a tag to compare
  • Add an arbitrary_precision feature which allows the serialization and deserialization of serde_json::Number to operate on data of arbitrary size/precision, rather than just fixed-width primitive integer and floating point types (#416, thanks @alexreg)

v1.0.12

19 Mar 05:40
v1.0.12
cc8e0b5
Compare
Choose a tag to compare

(dependency bump only)

v1.0.11

11 Mar 04:17
v1.0.11
42a5d68
Compare
Choose a tag to compare
  • Add a method Value::take similar to the method of the same name on Option (#421, thanks @dmizuk)

v1.0.10

28 Feb 01:05
v1.0.10
f2c385f
Compare
Choose a tag to compare
  • Improve error when a JSON string contains control character (#414, thanks @boxofrox)

v1.0.9

30 Dec 18:39
v1.0.9
c9cf70d
Compare
Choose a tag to compare
  • Hide implementation details of serde_json::Number from the Debug representation

v1.0.8

08 Dec 17:04
v1.0.8
b4e061f
Compare
Choose a tag to compare

Compatibility notes

Part of the improvement to compile time comes from having generic methods in serde_json instantiate many fewer Visitor trait methods than they used to. For example if a Deserialize impl is being deserialized from JSON and the impl indicates to Serde that the type u64 is expected, serde_json can avoid instantiating all of the Visitor methods that deal with string, borrowed string, unit, sequence, map, boolean, char, bytes, borrowed bytes, option, newtype, and enum. Previously all of these methods were instantiated and compile times were predictably poor in consequence. As of this release, serde_json instantiates only the expected Visitor methods and instead renders invalid_type error messages in a central place in the Deserializer that can be instantiated just once. This does not apply to deserialize_any for which it continues to be necessary to instantiate every Visitor method.

This does mean that code relying on the deserialize hint to be wrong may no longer deserialize successfully.

impl<'de> Deserialize<'de> for MyType {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
        where D: Deserializer<'de>
    {
        struct MyVisitor;

        impl<'de> Visitor<'de> for MyVisitor {
            type Value = MyType;

            fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {
                f.write_str("a string, although we ask the deserializer for u64")
            }

            fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
                where E: de::Error
            {
                Ok(/* ... */)
            }
        }

        // It used to be that serde_json would ignore this hint and call visit_str
        // for string input, but in the general case that destroys compile times
        // by instantiating far more Visitor methods than are ever used.
        deserializer.deserialize_u64(MyVisitor)
    }
}