Skip to content
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)] serializes "Option<>" incorrectly #148

Open
TaeHagen opened this issue Aug 6, 2024 · 1 comment
Open

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

TaeHagen opened this issue Aug 6, 2024 · 1 comment

Comments

@TaeHagen
Copy link

TaeHagen commented Aug 6, 2024

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
Copy link

Seems to be a duplicate of #55 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants