Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error roundtripping (regression from 1.0.25 to 1.0.38) #520

Closed
lutter opened this issue Feb 27, 2019 · 2 comments
Closed

Error roundtripping (regression from 1.0.25 to 1.0.38) #520

lutter opened this issue Feb 27, 2019 · 2 comments
Labels

Comments

@lutter
Copy link

lutter commented Feb 27, 2019

We need to roundtrip an enum that has an element Float(f32). That used to work with 1.0.25, but fails with 1.0.38. This gist has complete code that demonstrates the problem.

What happens is that the enum can be turned into a serde_json::Value, but trying to get the enum back from that causes the error invalid type: map, expected f32.

This is somewhat urgent, as it keeps us from updating other dependencies that use newer versions of serde_json (and we really need to update those).

For completeness sake, here is the serde_json::Value that fails to parse back to a Float(f32) and the error from my test program:

[src/main.rs:20] serde_json::to_value(v).unwrap() = Object(
    {
        "data": Number(159.10000610351562),
        "type": String(
            "Float"
        )
    }
)
[src/main.rs:25] serde_json::from_value::<Value>(jv) = Err(
    Error("invalid type: map, expected f32", line: 0, column: 0)
)
@dtolnay
Copy link
Member

dtolnay commented Feb 28, 2019

Sorry about the breakage! I released serde_json 1.0.39 with a fix.

@lutter
Copy link
Author

lutter commented Feb 28, 2019

Thanks so much for the super-quick turnaround on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants