Reputation: 195
I have json file as (test.json)
{
"items": [{
"instrument_name": "ABERDEEN",
"country_desc": "United Kingdom",
"region_desc": "Europe"
}, {
"instrument_name": "HLDGS LTD",
"country_desc": "China",
"region_desc": "APxJ"
}, {
"instrument_name": "RONS INC A",
"country_desc": "United States",
"region_desc": "US"
}]
}
i want to convert it into list of tuple i.e.
[("ABERDEEN","United Kingdom","Europe"),("HLDGS LTD","China","APxJ"),("RONS INC A","United States","US")]
Upvotes: 1
Views: 3310
Reputation: 73
x={
"items": [{
"instrument_name": "ABERDEEN",
"country_desc": "United Kingdom",
"region_desc": "Europe"
}, {
"instrument_name": "HLDGS LTD",
"country_desc": "China",
"region_desc": "APxJ"
}, {
"instrument_name": "RONS INC A",
"country_desc": "United States",
"region_desc": "US"
}]
}
items=x["items"]
[tuple(item.values()) for item in items]
Upvotes: 3