Ok found finaly the issue. You need to convert a nested dict first to a list.
scan_lijst_opti = []
for key, value in lijst.items():
dict_item = {}
dict_item['STOCK_ID'] = key
dict_item['STOCK_AANTAL'] = value['STOCK_AANTAL']
scan_lijst_opti.append(dict_item)