Internal buffering disrupts format-specific deserialization features
Was not sure if I should file this against `serde_json` or here. As far as I can tell the bug is more likely in serde itself. While implementing #1179 I noticed that non string keys are not supported for flattening. However the same behavior happens if buffering happens for internally tagged enums: Example that shows the problem: ```rust #[macro_use] extern crate serde_derive; extern crate serde; extern crate serde_json; use std::collections::HashMap; #[derive(Deserialize, Debug)] #[serde(tag = "type")] enum E { M(HashMap<u32, ()>), } fn main() { let j = r#" {"type": "M", "1": null} "#; println!("{}", serde_json::from_str::<E>(j).unwrap_err()); } ``` This currently fails with this error: ``` invalid type: string "1", expected u32 ``` However a `HashMap<u32, ()>` is otherwise entirely permissible by `serde_json`.
Posted by mitsuhiko on Mar 18, 2018, 8:12 PM
Tags
Related issues
- struct's lifetime requirements can be bypassed via covariant field assignment
- Proposal to Reorganize the Moderation Team and Review Moderation Policies
- Progressive FPS degradation appears to be related to dota2.com — blocking the domain prevents the performance loss
- proposal: container/...: generic collection types
- Better Custom Endpoint BYOK
- A concrete policy for backward compatibility until Godot 5.0
Raise real-world problems, find people facing the same issue, and discuss solutions.4,000 issues0 comments
github (Other)
struct's lifetime requirements can be bypassed via covariant field assignment
Proposal to Reorganize the Moderation Team and Review Moderation Policies
Progressive FPS degradation appears to be related to dota2.com — blocking the domain prevents the performance loss
proposal: container/...: generic collection types
Better Custom Endpoint BYOK
A concrete policy for backward compatibility until Godot 5.0
New MTP models not supported
Tracking: 429 / Capacity Issues
Internal buffering disrupts format-specific deserialization features
Was not sure if I should file this against `serde_json` or here. As far as I can tell the bug is more likely in serde itself. While implementing #1179 I noticed that non string keys are not supported for flattening. However the same behavior happens if buffering happens for internally tagged enums: Example that shows the problem: ```rust #[macro_use] extern crate serde_derive; extern crate serde; extern crate serde_json; use std::collections::HashMap; #[derive(Deserialize, Debug)] #[serde(tag = "type")] enum E { M(HashMap<u32, ()>), } fn main() { let j = r#" {"type": "M", "1": null} "#; println!("{}", serde_json::from_str::<E>(j).unwrap_err()); } ``` This currently fails with this error: ``` invalid type: string "1", expected u32 ``` However a `HashMap<u32, ()>` is otherwise entirely permissible by `serde_json`.
Comments (0)
No comments yet. Start the discussion.