我想返回多个json对象
def json_example():
for container in containers:
jsonresult = jsonify(Product = product_name , Price = final_price,Details = quantity)
return jsonresult
但这只返回一个json对象,我想返回多个json对象。 这将返回
{"Details": "1 L",
"Price": "275",
"Product": "HARPIC BATHROOM FLOOR CLEANER 1000 ml lemon}
答案 0 :(得分:0)
尝试一下:
the_dict = dict()
def json_example(the_dict):
for container in containers:
jsonresult = jsonify(Product = product_name , Price = final_price,Details = quantity)
the_dict[container] = jsonresult
return the_dict
现在the_dict
应该包含所有json对象。您还可以建立一个列表并将其追加。