Skip to content

Error roundtripping (regression from 1.0.25 to 1.0.38) #520

@lutter

Description

@lutter

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)
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions