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

Serialization does not work with serde_with::skip_serializing_none #41

Closed
IgnisDa opened this issue Jan 26, 2024 · 5 comments
Closed

Serialization does not work with serde_with::skip_serializing_none #41

IgnisDa opened this issue Jan 26, 2024 · 5 comments
Labels
bug Something isn't working feature:serde Issue or pull related to Serde integration

Comments

@IgnisDa
Copy link

IgnisDa commented Jan 26, 2024

This was the reason #40 happened for me. Removing #[skip_serializing_none] from my struct gets everything working again.

Ref: https://docs.rs/serde_with/3.1.0/serde_with/attr.skip_serializing_none.html

@IgnisDa IgnisDa added the bug Something isn't working label Jan 26, 2024
@IgnisDa
Copy link
Author

IgnisDa commented Jan 26, 2024

It would be great if skip_serializing_none is supported since otherwise there are a lot of nulls in the export performed.

@Marcono1234
Copy link
Owner

Thanks for the report! I was able to reproduce this locally. The Serializer implementation in Struson validates the provided len to methods such as serialize_struct, but it seems I got the handling in skip_field incorrect, leading to the error you are seeing. I will fix that in that next days.

However, I am also considering removing validation of the len (see #42) since Serde JSON's implementation does not validate it either.

@IgnisDa
Copy link
Author

IgnisDa commented Jan 29, 2024

Thanks for taking a look!

However, I am also considering removing validation of the len (see #42) since Serde JSON's implementation does not validate it either.

In my case, since the JSON is already validated, the struson validation is not required. But maybe you are aware of use-cases where it might be required. Either way, it is fine if you remove the validation for my use-case.

@Marcono1234 Marcono1234 added the feature:serde Issue or pull related to Serde integration label Jan 30, 2024
@Marcono1234
Copy link
Owner

This should be fixed in version 0.4.1, please let me know if you encounter any other issues.

And thanks for considering to use Struson!

@IgnisDa
Copy link
Author

IgnisDa commented Jan 31, 2024

Works perfectly now, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feature:serde Issue or pull related to Serde integration
Projects
None yet
Development

No branches or pull requests

2 participants