Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flask restful parser list dictionary

Tags:

rest

flask

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 ?

like image 471
Vix Lee Avatar asked Mar 03 '16 06:03

Vix Lee


1 Answers

Use something like this :)

self.postreqparse = reqparse.RequestParser()
self.postreqparse.add_argument("shopping_cart", type=dict, action="append")
like image 117
Marco Mendão Avatar answered Sep 17 '22 17:09

Marco Mendão