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

Can a tag name be used as a struct's attribute? #184

Open
antis81 opened this issue May 19, 2024 · 0 comments
Open

Can a tag name be used as a struct's attribute? #184

antis81 opened this issue May 19, 2024 · 0 comments

Comments

@antis81
Copy link

antis81 commented May 19, 2024

The source XML I am serializing looks like this:

<property name="abc">
  <string>Hello World!</string>
</property>

Now I like to use the "string" to differentiate property types (string, bool, int, …).

#[derive(PartialEq, Debug, YaDeserialize)]
#[yaserde(rename = "property")]
pub struct Property {
    #[yaserde(attribute)]
    pub name: String,
    #[yaserde()]
    pub value: Option<PropertyValue>,
}

#[derive(PartialEq, Debug, YaDeserialize)]
pub struct PropertyValue {
    #[yaserde(tag)]
    pub prop_type: String,
    #[yaserde()]
    pub prop_value: String,
}

Is it implemented already? I couldn't find any documentation about that.

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

1 participant