Flask restful parser list dictionary

时间:2016-03-03 06:36:28

标签: rest flask

我有一个示例解析请求列表字典:

{
    "shopping_cart": [{
        "id": 23323,
        "qty": 10
    }, {
        "id": 34232,
        "qty": 9
    }, {
        "id": 34232,
        "qty": 9
    }]
}

我如何解析它使用flask_restful RequestParser?

1 个答案:

答案 0 :(得分:3)

使用类似的东西:)

self.postreqparse = reqparse.RequestParser()
self.postreqparse.add_argument("shopping_cart", type=dict, action="append")