Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Unable to output single line array syntax #355

Open
mabushey opened this issue Feb 23, 2023 · 2 comments
Open

Unable to output single line array syntax #355

mabushey opened this issue Feb 23, 2023 · 2 comments

Comments

@mabushey
Copy link

❤️ First off, serde is amazing. :)

I'm using serde_yaml::to_writer() to dump a struct to a yaml file. In the struct I have tmdb_genre: Vec<u64> which outputs like this:

tmdb_genre:
- 35
- 10751
- 9648
- 10749

While this is correct yaml, for purely aesthetic reasons I would like it to look like this:

tmdb_genre: [35, 10751, 9648, 10749]

I tried adding #[serde(flatten)] to the struct element but I get runtime Error("can only flatten structs and maps (got a sequence)"). Is there any way of doing this w/o resorting to post processing of the yaml (ie sed)? Thanks!

@AurelienFT
Copy link

Did you found the solution?

@mabushey
Copy link
Author

Did you found the solution?

Nope, doing a system call to sed afterwards. Thanks for asking. :)

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

No branches or pull requests

2 participants