Last active
February 27, 2019 23:49
-
-
Save lutter/2820e2c98331d5b5b6b95d62912e2e0f to your computer and use it in GitHub Desktop.
serde_json regression from 1.0.25 to 1.0.38
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "json" | |
version = "0.1.0" | |
authors = ["David Lutterkort <lutter@watzmann.net>"] | |
edition = "2018" | |
[dependencies] | |
serde_json = { version = "=1.0.38", features = ["arbitrary_precision"] } | |
#serde_json = { version = "=1.0.25", features = ["arbitrary_precision"] } | |
serde_derive = "1.0.88" | |
serde = "1.0.88" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[macro_use] | |
extern crate serde_derive; | |
extern crate serde_json; | |
extern crate serde; | |
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] | |
#[serde(tag = "type", content = "data")] | |
pub enum Value { | |
String(String), | |
Int(i32), | |
// Changing this to f64 makes the example work with 1.0.38 | |
Float(f32), | |
Bool(bool), | |
List(Vec<Value>), | |
Null | |
} | |
fn main() { | |
let v = Value::Float(159.1); | |
let jv = dbg!(serde_json::to_value(v).unwrap()); | |
// This works with serde_json 1.0.25, but not 1.0.38 | |
// With that, the error is | |
// "invalid type: map, expected f32" | |
let v = dbg!(serde_json::from_value::<Value>(jv)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment