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

Serializing a vector fails #135

Closed
Stock84-dev opened this issue Jul 19, 2020 · 11 comments
Closed

Serializing a vector fails #135

Stock84-dev opened this issue Jul 19, 2020 · 11 comments

Comments

@Stock84-dev
Copy link

Serializing struct with vector fails with:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: UnsupportedOperation { operation: "serialize_seq" }.
I see that unit tests contain vectors so it should be supported. But they are marked with #[ignore]
Demo code:

#[derive(Serialize, Deserialize)]
struct ABC {
    abc: f32,
}

#[derive(Serialize, Deserialize)]
struct ABC2 {
    #[serde(rename = "$value", default)]
    items: Vec<ABC>,
}

fn main() {
    let abc = ABC2 {
        items: vec![ABC { abc: 1. }],
    };
    debug!("{:#?}", serde_xml_rs::to_string(&abc).unwrap());
}
@elmarco
Copy link

elmarco commented Jul 23, 2020

I think this should be fixed with #129.

@ewpratten
Copy link

I get to the very end of a project and discover this doesn't work..

@zhiburt
Copy link

zhiburt commented Jun 5, 2021

Also get the same for this structure

#[derive(Debug, Serialize, Deserialize)]
pub struct Data {
    pub name: String,
    pub list: Vec<bool>,
}

@woelper
Copy link

woelper commented Jun 12, 2021

Sorry for being a bit off-topic, but I ran into the same issue as well and found a workaround: you could try to use https://github.com/tafia/quick-xml as a drop-in replacement until this issue is resolved.

@ewpratten
Copy link

@woelper That ended up being my solution too.

@Curricane
Copy link

how can i serialize a struct with vec?!

@punkstarman
Copy link
Collaborator

Sorry that the serializer isn't complete yet. As soon as I have some time, I've got some stuff in the works for revamping and completing the serializer.

@Curricane, if you are in a hurry, you can have a look at the project where I did some experimentation: https://github.com/punkstarman/serde-xml

@zmrow
Copy link

zmrow commented Jul 27, 2022

@punkstarman Does the serializer completed in #173 and mentioned as a solution to #76 also fix this issue?

If so, is there any chance of a release in the near future?

@punkstarman
Copy link
Collaborator

@zmrow I will check and try to release in the next week.

@punkstarman
Copy link
Collaborator

I just released a new version.

@punkstarman
Copy link
Collaborator

punkstarman commented Sep 1, 2022

This appears to be fixed in the new version.

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

8 participants