python/flask – Trim json response and /or print only certain values for each record in response

I make a call to my api and receive a response back in the below format. I can receive anywhere from 0 to 20 records. The below shows 2. I am wanting to achieve two things.

  1. How can I iterate through and print only the ‘properties’ values for each record. So the below would look something like

test 20934120

test 20934121

  1. Would it then be possible to turn all the properties back into json so I end up with a trimmed down version of my original response that only includes the properties values for each record as valid json.


    {'count': 2, 'total': 2, 
    'data': [
    {'id': '6a3d7026-43f3-67zt-9211-99dfc6fee82e', 
     'name': 'test',  
     'properties': {'Description#en': 'test', 'Number#en': '20934120'},
    {'id': '6a3d7026-43f3-67zt-9211-99hdttbhh4ed', 
     'name': 'test',  
     'properties': {'Description#en': 'test', 'Number#en': '20934121'}}], 

How I am parsing the response and outputting the values from the first record.


response = requests.request("GET", url, headers=headers, data=payload)

data = json.loads(response.text)

#Output first value num and description
inc_number = (data['data'][0]['properties']['Number#en'])
inc_id = (data['data'][0]['properties']['Description#en'])


json_example = {
    "count": 2,
    "total": 2,
    "data": [
            "id": "6a3d7026-43f3-67zt-9211-99dfc6fee82e",
            "name": "test",
            "properties": {"Description#en": "test", "Number#en": "20934120"},
            "id": "6a3d7026-43f3-67zt-9211-99hdttbhh4ed",
            "name": "test",
            "properties": {"Description#en": "test", "Number#en": "20934121"},

properties = [item["properties"] for item in json_example["data"]]
# >> [{'Description#en': 'test', 'Number#en': '20934120'}, {'Description#en': 'test', 'Number#en': '20934121'}]

properties_values = [list(property.values()) for property in properties]
# >> [['test', '20934120'], ['test', '20934121']]

for property in properties_values:
    print(" ".join(property))
# >> test 20934120
# >> test 20934121