{
"data": [
{
"id": 1,
"attributes": {
"name": "Company1",
"regions": {
"data": [
{
"id": 1,
"attributes": {
"name": "Ленинградская область",
}
},
{
"id": 2,
"attributes": {
"name": "Московская область",
}
},
{
"id": 3,
"attributes": {
"name": "Волгоградская область",
}
},
]
}
}
},
{
"id": 2,
"attributes": {
"name": "Company2",
"regions": {
"data": [
{
"id": 1,
"attributes": {
"name": "Ленинградская область",
}
},
{
"id": 2,
"attributes": {
"name": "Московская область",
}
}
]
}
}
},
],
}
import os
import json
import requests
BASE_URL = 'localhost'
res = requests.get(BASE_URL)
res_content = json.loads(res.content)
for holding in res_content['data']:
print(holding['id'], holding['attributes']['name'])