Skip to content

Support seq and maps (refactor of #129) #142

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

Conversation

adrianbenavides
Copy link

@adrianbenavides adrianbenavides commented Sep 30, 2020

Based on #129

This MR adds support to serialize maps and vectors. Example:

#[derive(Serialize)]
#[serde(rename = "team")]
struct Team {
    people: Vec<Person>,
}

#[derive(Serialize)]
#[serde(rename = "person")]
struct Person {
    name: String,
}

will get serialized as:

<team>
    <people>
        <person>
            <name>Joe</name>
        </person>
        <person>
            <name>Jane</name>
        </person>
    </people>
</team>

Note: the pipeline fails at the same test as the master branch (test_doctype_fail)

@adrianbenavides adrianbenavides changed the title Feat: support seq and maps Support seq and maps (refactor of #129) Sep 30, 2020
src/ser/mod.rs Outdated

let got = String::from_utf8(buffer).unwrap();
assert_eq!("<Thing><things>thing_1thing two</things></Thing>", got);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is the expected behavior, but we can't do much to separate the vector items if we don't have any tag. To properly serialize vectors we should use types that wraps a vector such as MyStruct(Vec<String>).

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

Successfully merging this pull request may close these issues.

1 participant