-
Notifications
You must be signed in to change notification settings - Fork 4
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
#[serde(flatten)] crashes when trying to serialize #52
Comments
I believe on the latest version this should emit an error instead of panicking at least (unless you're the one panicking of course) Can you update your repro with the definition for |
Ope, spoke too soon. I haven't released those changes yet, so that's only on |
just realized i used serde_json::Value, i think this might be what caused the panic. then i will retest it |
hmm this also fails: #[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename = "AppState")]
struct AppManifestFile {
#[serde(rename = "appid")]
pub app_id: String,
pub name: String,
#[serde(rename = "AutoUpdateBehavior")]
pub auto_update_behavior: String,
#[serde(flatten)]
other: HashMap<String, String>,
} this is the data:
and here is a debug print of the AppManifest object:
|
Perfect, thanks! I'll try to figure out a fix sometime next week |
here is a full example: use std::collections::HashMap;
use keyvalues_serde;
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize)]
struct Foo {
#[serde(rename = "KnownField")]
known_field: String,
#[serde(rename = "KnownFieldTwo")]
known_field_two: String,
#[serde(flatten)]
other: HashMap<String, String>
}
fn main() {
let input = r##"
"Foo"
{
"KnownField" "0"
"KnownFieldTwo" "1"
"UnknownField" "2"
}
"##;
let serialized: Foo = keyvalues_serde::from_str(input).unwrap();
let back_to_string = keyvalues_serde::to_string(&serialized).unwrap(); // panics here
} |
deserializing works.
but when converting this object back to a string, it panics with this message:
Expected key, found: Some(ObjBegin)
The text was updated successfully, but these errors were encountered: