Deserializing only specific fields from a schema in fields.Nested?
See original GitHub issueThe only
parameter for fields.Nested
only applies to serialization.
Since you can only pass the schema class or name string to fields.Nested
, there is currently no way to limit which fields are deserialized. Schema.__init__()
allows use of dump_only
and load_only
, but these cannot currently be used with fields.Nested
.
Is there a way to limit which fields are deserialized from a nested schema?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Nesting Schemas — marshmallow 3.19.0 documentation
Specifying Which Fields to Nest¶. You can explicitly specify which attributes of the nested objects you want to (de)serialize with the only argument...
Read more >deserializing nested schema with only one exposed key
For anyone stumbling across the same issue, this is the workaround I am using currently: class MySchema(Schema): key = fields.
Read more >Marshmallow Deserialize Nested Schema - Python Help
Hi everyone, I am trying to find a way to deserialize a json object using Marshmallow. ... class CustomerDTO(BaseDTO): first_name: str = fields....
Read more >great_expectations.marshmallow__shade.schema
Metaclass for the Schema class. Binds the declared fields to a _declared_fields attribute, which is a dictionary mapping attribute names to field objects....
Read more >How to use the marshmallow.fields.Method function in ... - Snyk
To help you get started, we've selected a few marshmallow.fields.Method examples, based on ... ModelSchema): reservation = Nested(ReservationSchema) state ...
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
I believe the desired behavior is already implemented–the
only
parameter is respected upon deserialization. I’ve verified that @joshfriend 's code example works in both marshmallow 2.13.3 and 3.0.0b1.I’m more interested in using
only
to ignore any extra info the client might send, rather than accepting however many fields the client wants to send. I thinkpartial
will already apply to nested schemas if it is given on the parent.