ebarnard / rust-plist

A rusty plist parser.
MIT License
71 stars 42 forks source link

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

Open TaeHagen opened 2 months ago

TaeHagen commented 2 months ago

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.

zhaofengli commented 2 weeks ago

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