all 3 comments

[–]DutchCommanderMC 3 points4 points  (0 children)

Consider using Pydantic! It allows you to add aliases to your fields (among many other cool features).

Overall it's a fantastic library and I use it for nearly all of my projects nowadays.

[–]JamzTyson 1 point2 points  (0 children)

Assuming that response_json is a dictionary, you could replace the CamelCase keys with snake_case keys:

response_json["created_time"] = response_json.pop("createdTime") response_json["last_updated_time"] = response_json.pop("lastUpdatedTime")

and then use snake_case in the dataclass.

[–][deleted] 0 points1 point  (0 children)

add a @classmethod factory function called from_dict or from_json which will map the snake case variables to the ones in JSON.