I am deliberating about how to transfer the complex information from a JSON API response to (several) Python objects. I have included the (lengthy) model response below. Note that some values are not always included in the response, and some values are a list of dictionaries.
Is there an "easy" way to map the JSON response to Python objects? How would I ideally lay out the classes?
Model JSON response:
{
"accounts" : {
"accounting_reference_date" : {
"day" : "integer",
"month" : "integer"
},
"last_accounts" : {
"made_up_to" : "date",
"period_end_on" : "date",
"period_start_on" : "date",
"type" : "string"
},
"next_accounts" : {
"due_on" : "date",
"overdue" : "boolean",
"period_end_on" : "date",
"period_start_on" : "date"
},
"next_due" : "date",
"next_made_up_to" : "date",
"overdue" : "boolean"
},
"annual_return" : {
"last_made_up_to" : "date",
"next_due" : "date",
"next_made_up_to" : "date",
"overdue" : "boolean"
},
"branch_company_details" : {
"business_activity" : "string",
"parent_company_name" : "string",
"parent_company_number" : "string"
},
"can_file" : "boolean",
"company_name" : "string",
"company_number" : "string",
"company_status" : "string",
"company_status_detail" : "string",
"confirmation_statement" : {
"last_made_up_to" : "date",
"next_due" : "date",
"next_made_up_to" : "date",
"overdue" : "boolean"
},
"date_of_cessation" : "date",
"date_of_creation" : "date",
"etag" : "string",
"external_registration_number" : "string",
"foreign_company_details" : {
"accounting_requirement" : {
"foreign_account_type" : "string",
"terms_of_account_publication" : "string"
},
"accounts" : {
"account_period_from" : {
"day" : "integer",
"month" : "integer"
},
"account_period_to" : {
"day" : "integer",
"month" : "integer"
},
"must_file_within" : {
"months" : "integer"
}
},
"business_activity" : "string",
"company_type" : "string",
"governed_by" : "string",
"is_a_credit_finance_institution" : "boolean",
"originating_registry" : {
"country" : "string",
"name" : "string"
},
"registration_number" : "string"
},
"has_been_liquidated" : "boolean",
"has_charges" : "boolean",
"has_insolvency_history" : "boolean",
"is_community_interest_company" : "boolean",
"jurisdiction" : "string",
"last_full_members_list_date" : "date",
"links" : {
"charges" : "string",
"filing_history" : "string",
"insolvency" : "string",
"officers" : "string",
"persons_with_significant_control" : "string",
"persons_with_significant_control_statements" : "string",
"registers" : "string",
"self" : "string"
},
"partial_data_available" : "string",
"previous_company_names" : [
{
"ceased_on" : "date",
"effective_from" : "date",
"name" : "string"
}
],
"registered_office_address" : {
"address_line_1" : "string",
"address_line_2" : "string",
"care_of" : "string",
"country" : "string",
"locality" : "string",
"po_box" : "string",
"postal_code" : "string",
"premises" : "string",
"region" : "string"
},
"registered_office_is_in_dispute" : "boolean",
"sic_codes" : [
"string"
],
"subtype" : "string",
"type" : "string",
"undeliverable_registered_office_address" : "boolean"
}