Python: Query Dict to JSON

前端 未结 3 851
遥遥无期
遥遥无期 2021-01-02 11:34

I am trying to send some JSON to my django app in a query string by using encodeURIComponent() my server enpoint receives the data just fine as I can print it t

3条回答
  •  温柔的废话
    2021-01-02 12:14

    QueryDict class is a subclass of regular Python dictionary, except that it handles multiple values for a same key (see MultiValueDict implementation).

    If you want to dump it to a string, just use json.dumps():

    json.dumps(my_query_dict) 
    

    There is also a relevant dict() method:

    QueryDict.dict()

    Returns dict representation of QueryDict.

提交回复
热议问题