attribute used instead of data_key during deserialization
See original GitHub issueThis may be related to #748. When a data_key is provided for a field the deserialized data contains the wrong key.
import marshmallow as mm
class TestSchema(mm.Schema):
type = mm.fields.String(attribute='_type', data_key='type')
data = {
'type': 'value'
}
assert TestSchema().load(data) == data
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Fields — marshmallow 3.19.0 documentation
attr – The attribute/key in data to be deserialized. ... fields for a single attribute. In most cases, you should use data_key instead....
Read more >How to handle overflow JSON or use JsonElement or ...
Learn how to handle overflow JSON or use JsonElement or JsonNode while using System.Text.Json to serialize and deserialize JSON in .NET.
Read more >Use DataMember during deserialize but nut during serialize?
This works fine and the data is mapped to the internal property name. At some point I have to serialize this object again...
Read more >marshmallow -- simplified object serialization | We all are data.
One common use case is to wrap data in a namespace upon serialization and unwrap the data during deserialization. from marshmallow import Schema ......
Read more >Eloquent: API Resources - Laravel - The PHP Framework For ...
For example, you may wish to display certain attributes for a subset of ... To generate a resource class, you may use 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
Use one schema for loading and one for dumping.
I’ll just delete the
_type
key so I don’t have to update all my models. Thanks for your help! This issue can be closed.