I am fetching from an API and getting a JSON response like so:
{
"features": {
"due_dates": {
"enabled": true,
"start_date": false,
"remap_due_dates": true,
"remap_closed_due_date": false
},
"sprints": {
"enabled": false
},
"points": {
"enabled": false
},
"custom_items": {
"enabled": false
},
"tags": {
"enabled": true
},
"time_estimates": {
"enabled": true
},
"checklists": {
"enabled": true
},
"zoom": {
"enabled": false
},
"milestones": {
"enabled": false
},
"custom_fields": {
"enabled": true
},
"remap_dependencies": {
"enabled": true
},
"dependency_warning": {
"enabled": true
},
"multiple_assignees": {
"enabled": true
},
"portfolios": {
"enabled": true
},
"emails": {
"enabled": true
}
}
I have a class setup like so:
class Features(BaseModel):
multiple_assignees: bool = False
start_date: bool = False
remap_due_dates: bool = False
remap_closed_due_date: bool = False
time_tracking: bool = False
tags: bool = False
time_estimates: bool = False
checklists: bool = False
custom_fields: bool = False
remap_dependencies: bool = False
dependency_warning: bool = False
portfolios: bool = False
points: bool = False
custom_items: bool = False
zoom: bool = False
milestones: bool = False
emails: bool = False
What I would like to do is unpack this JSON into the features object and use the value from the "enabled" key for each corresponding attribute. I want to do it this way to avoid having to set up a class for sprints, points, custom_items, etc. Is it possible to just get the nested "enabled" bool values and skip over setting up a class for each?