-
Notifications
You must be signed in to change notification settings - Fork 41
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
Omit the corresponding key/value pairs when the value is None
to use TOML serialization
#421
Comments
What happens if I still cannot wrap my head around why TOML is fighting against having |
Hi sorry for the delay. I was just back from vacation. What will happen if you pass an object with null property to toml? |
@yukinarit It will raise an error and stop serializing. |
The `skip_none` attribute is an optional feature originally implemented to prevent null values from appearing in TOML serialized outputs. When set to True, any field in the class with a None value is excluded from the serialized output, ensuring that TOML files (or other formats) remain clean and free from null entries. Closes #421
The `skip_none` attribute is an optional feature originally implemented to prevent null values from appearing in TOML serialized outputs. When set to True, any field in the class with a None value is excluded from the serialized output, ensuring that TOML files (or other formats) remain clean and free from null entries. Closes #421
The `skip_none` attribute is an optional feature originally implemented to prevent null values from appearing in TOML serialized outputs. When set to True, any field in the class with a None value is excluded from the serialized output, ensuring that TOML files (or other formats) remain clean and free from null entries. Closes #421
Hi @drunkwcodes I finally took some time to solve this issue! pyserde v0.21.0 can automatically omit NOTE: This works for dataclass fields level only, not array not dict. Refer to test_toml.py to understand the detailed behavior. |
@yukinarit thank you for your persistent hard work. I'm looking at it right now. |
I asked Toml maintainers to add
null
to TOML spec, and I got the reply which suggest me to omit the null key/value pairs.toml-lang/toml#975
It is usual in python to use None, and TOML can not be used in these cases.
I really like TOML, can
pyserde
adjust serialization procedure to overcome this restriction?The text was updated successfully, but these errors were encountered: