rust-plist icon indicating copy to clipboard operation
rust-plist copied to clipboard

#[serde(flatten)] serializes "Option<>" incorrectly

Open TaeHagen opened this issue 1 year ago • 1 comments

When using this crate, a setup such as this one generates an incorrect plist.

#[derive(Serialize)]
    struct Annoying {
        #[serde(flatten)]
        second: Second,
    }

    #[derive(Serialize)]
    struct Second {
        test: Option<String>,
    }

    let test = Annoying {
        second: Second {
            test: Some("to".to_string())
        }
    };

    println!("plist {}", plist_to_string(&test).unwrap())

Gives the incorrect output of:

<dict>
	<key>test</key>
	<dict>
		<key>Some</key>
		<string>to</string>
	</dict>
</dict>

Correct output:

<dict>
	<key>test</key>
	<string>to</string>
</dict>

Thank you.

TaeHagen avatar Aug 06 '24 03:08 TaeHagen

Seems to be a duplicate of https://github.com/ebarnard/rust-plist/pull/55#issuecomment-771113306

zhaofengli avatar Sep 30 '24 21:09 zhaofengli