Reputation: 339
I can't seem to be able to figure out how to extra all but the list inside this json object. The error I keep getting is ValueError: too many values to unpack (expected 2)
.
data = { k:v for (k, v) in organization_types_json if k != organization_types_json['organization_type_names']}
Json:
{
"is_active": 0,
"is_delete": 1,
"organization_type_names": [{
"lang": "EN",
"name": "Fire"
}, {
"lang": "FR",
"name": "Feu"
}]
}
Upvotes: 1
Views: 50
Reputation: 26994
You need to add .items()
like so:
data = { k:v for (k, v) in organization_types_json.items() if k != 'organization_type_names'}
Or extract all and remove that item.
d = dict(organization_types_json)
del d['organization_type_names']
Upvotes: 2