[question] Skip missing fields instead of default values
See original GitHub issueI have tried to find answer myself but failed - it seems it is not supported right now.
In case if I’ve missed it: is it possible to skip missing fields instead of assigning default values during serialization?
I will try to describe it in example:
some_data = dict(
first_name='Joe',
age=20,
)
class TestSchema(Schema):
first_name = String()
family_name = String()
age = Integer()
schema = TestSchema()
print(schema.dump(some_data).data)
Current result: OrderedDict([('first_name', u'Joe'), ('family_name', ''), ('age', 20)])
Desired result: OrderedDict([('first_name', u'Joe'), ('age', 20)])
Of course it is possible to filter the result afterwards. Although it is quite tricky due to the different default values (i.e. for strings, integers) but possible and I’ve already done it.
I am just curious if I’ve missed some core functionality.
Issue Analytics
- State:
- Created 9 years ago
- Comments:11 (9 by maintainers)
Top Results From Across the Web
set default values for fields when using skip logic in qualtrics
If a user selects '1' for Yes, I know how to easily skip the next 5 questions in Qualtrics. But, I don't just...
Read more >Checking if a scalar field is truly missing (not set to default ...
I know there is a checkField function that tells whether a field is missing but it does not distinguish between a missing field...
Read more >Set default values for blank fields in Zaps - Zapier
Set default values for blank fields in Zaps · 1. Add Formatter to your Zap · 2. Set up the Default Value text...
Read more >Default Value for Skipped Question - Support - ODK Forum
i tried using a default value for skipped questions but default value disappears when i skip and unskip the question it replaces the...
Read more >Expressions - Apache FreeMarker Manual
Default value operator; Missing value test operator ... Note that the character sequence ${ and #{ (and rarely [= instead, depending on the ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
An update: skipping missing values is now the default behavior in marshmallow 2.0.0: https://marshmallow.readthedocs.org/en/latest/upgrading.html#default-values
For this reason, I think I’m going to go ahead and deprecate the
skip_missing
option.