JSON – Solution [0]
import json
sampleJson = """{
"company":{
"employees":[
{
"name":"emma",
"payable":{
"salary":7000,
"bonus":800
}
},
{
"name":"anna",
"payable":{
"salary":5500,
"bonus":1000
}
}
]
}
}"""
content = json.loads(sampleJson)
employees = content.get("company", {}).get("employees", [])
for employee in employees:
name = employee.get('name')
if name == "emma":
payable = employee.get("payable", {})
total = payable.get("salary", 0) + payable.get("bonus", 0)
print(f"{name} has a total salary with bonus: {total}")