在烧瓶中返回多个json对象

时间:2020-05-19 11:59:17

标签: json flask

我想返回多个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}

1 个答案:

答案 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对象。您还可以建立一个列表并将其追加。