Timeline for Deserializing JSON list into class objects not able to extract attributes
Current License: CC BY-SA 4.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 5 at 2:10 | comment | added | STerliakov |
Your __init__ takes 4 arguments, but you pass 7 in from_json (and probably in wrong order). Did you intend to accept all 7 instead of setting three of attributes to None ? If so, that'd be a perfect dataclass , and you'll be able to load with [LeagueAcc.from_json(entry) for entry in json.loads(json_object)] .
|
|
Jul 5 at 1:04 | history | edited | toyota Supra | CC BY-SA 4.0 |
added 10 characters in body; edited title
|
Jul 5 at 0:47 | vote | accept | Peter K | ||
Jul 4 at 22:56 | comment | added | Barmar |
The problem with your method is that object_hook will be called for the top-level object, not just the objects in the list.
|
|
Jul 4 at 22:55 | history | edited | Barmar | CC BY-SA 4.0 |
formatting
|
Jul 4 at 22:52 | answer | added | Victor Egiazarian | timeline score: 0 | |
Jul 4 at 22:40 | history | asked | Peter K | CC BY-SA 4.0 |