‘import json

data = data = ‘{
“case”: [
{
“ref_id”: “string”,
“case_status”: “PRC”,
“referral_submitted_date”: “2023-04-24”,
“modified_by”: 0,
“lead_id”: 1,
“loan_amount”: 0,
“deal_lost_date”: “2023-04-24”,
“modified_at”: “2023-04-21”,
“property_type”: “string”,
“hkmc_needed”: 0,
“customer_name”: “string”,
“completion_date”: “2023-04-24”,
“remarks”: “string”,
“customer_phone_number”: 0,
“drawdown_date”: “2023-04-24”,
“accepted_offer”: “string”,
“id”: 5,
“customer_contact_number”: 0,
“bank_received_application”: “{string}”,
“predicted_offer”: “string”,
“address”: “string”,
“referral_code”: “another code”,
“created_by”: 0,
“actual_drawdown_amt”: 0,
“created_at”: “2023-04-21”
},
{
“ref_id”: “string”,
“case_status”: “PRC”,
“referral_submitted_date”: “2023-04-24”,
“modified_by”: 0,
“lead_id”: 1,
“loan_amount”: 123456,
“deal_lost_date”: “2023-04-24”,
“modified_at”: “2023-04-21”,
“property_type”: “property type”,
“hkmc_needed”: 0,
“customer_name”: “vinci”,
“completion_date”: “2023-04-24”,
“remarks”: “money, i need money”,
“customer_phone_number”: 999,
“drawdown_date”: “2023-04-24”,
“accepted_offer”: “refused”,
“id”: 2,
“customer_contact_number”: 1122334455,
“bank_received_application”: “{HSBC}”,
“predicted_offer”: “infinity”,
“address”: “wan chai”,
“referral_code”: “referral_c0de”,
“created_by”: 0,
“actual_drawdown_amt”: 123456,
“created_at”: “2023-04-21”
}
],
“lead”: [
{
“id”: 1,
“customer_name”: “also vinci in lead”,
“customer_contact_phone”: 1234567890,
“remarks”: “Additional remarks”,
“created_by”: “John”,
“customer_phone”: 1234567890,
“lead_type_id”: “L1001”,
“submitted_referal_form”: true,
“lead_source”: “Source A”,
“created_at”: “2023-04-24”
}
],
“rebate”: [
{
“received_date”: “2023-04-24”,
“loan_amount”: 0,
“rebate_to_referrer”: “string”,
“received_year”: 0,
“referral_code”: “referral_c0de”,
“commission_to_sales”: “string”,
“handler”: “vinci”,
“date_sent_to_HKEAA”: “2023-04-24”,
“net_income”: 0,
“created_at”: “2023-04-24”,
“source”: “vinci”,
“commission_received_date”: “2023-04-24”,
“percentage_fee_rebate_borrower_sales_referrer”: 0,
“created_by”: “0”,
“id”: 1,
“borrower_name”: “vinci”,
“total_commission”: 0,
“percentage_rebate_to_borrower”: 0,
“mortgage_address”: “address”,
“commission_to_association”: 0,
“percentage_to_imort”: 0,
“ref_no”: “string”,
“status”: “string”,
“commission_to_imort”: 0,
“net_percentage_to_imort”: 0,
“drawdown_date”: “2023-04-24”,
“received_month”: 0
},
{
“received_date”: “2023-04-26”,
“loan_amount”: 0,
“rebate_to_referrer”: “string”,
“received_year”: 0,
“referral_code”: “another code”,
“commission_to_sales”: “string”,
“handler”: “string”,
“date_sent_to_HKEAA”: “2023-04-26”,
“net_income”: 0,
“created_at”: “2023-04-26”,
“source”: “string”,
“commission_received_date”: “2023-04-26”,
“percentage_fee_rebate_borrower_sales_referrer”: 0,
“created_by”: “0”,
“id”: 2,
“borrower_name”: “string”,
“total_commission”: 0,
“percentage_rebate_to_borrower”: 0,
“mortgage_address”: “string”,
“commission_to_association”: 0,
“percentage_to_imort”: 0,
“ref_no”: “string”,
“status”: “string”,
“commission_to_imort”: 0,
“net_percentage_to_imort”: 0,
“drawdown_date”: “2023-04-26”,
“received_month”: 0
}
]
}’

data_dict = json.loads(data)

result = {}
for key in data_dict:
for case in data_dict[key]:
if isinstance(case, dict):
if ‘i’ in str(value) and len(case.keys()) == 2:
result[key] = ‘i’
break

print(result)
’
base on this above code,
show me the example output in both which has the len(case.keys()) == 2 or not

also u can make the another version which looks better