Is it possible to translate keys to class properties in dataclasses? The reason is that the keys in the dict (which I cut out from a JSON file) does not have matching attribute names in JSON (e.g. _id in the below example has to become id).
With the code below I feel like I'm writing too much boilerplate.
Dict:
{'_id': '5719fdf6edf5136d37aaf562', 'divespot': 'The Tugs', 'divesite': 'Fathom Five National Park', 'region': 'Ontario', 'country': 'Canada'}
class:
class DiveSpot:
id: str
name: str
def from_dict(self, divespot):
self.id = divespot.get("_id")
self.name = divespot.get("divespot")