Vix Lee
Vix Lee

Reputation: 91

Flask restful parser list dictionary

I have an example parse request list dictionary:

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

How can i parse it use flask_restful RequestParser ?

Upvotes: 8

Views: 4198

Answers (1)

Marco Mendão
Marco Mendão

Reputation: 329

Use something like this :)

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

Upvotes: 15

Related Questions