lidatong / dataclasses-json

Easily serialize Data Classes to and from JSON
MIT License
1.34k stars 150 forks source link

Added in a more user-friendly error message for when a field is missi… #503

Open genixpro opened 7 months ago

genixpro commented 7 months ago

Previously this code was just crashing if I attempted to decode JSON with a field missing. Now it will crash with an error message that indicates more precisely what is actually happening.

george-zubrienko commented 7 months ago

@genixpro looks like this breaks the test suite:

raise TypeError( f"The JSON data is missing the required field '{field.name}' when decoding {cls.name} from JSON." )

Maybe you can have a look why?