How to do JSON handler in Django

前端 未结 2 1979
一个人的身影
一个人的身影 2021-01-11 12:31

I want to get and parse json in django view.

Requst in template:

var values = {};
$(\"input[name^=\'param\']\").each(function() {
    values[$(this).         


        
相关标签:
2条回答
  • 2021-01-11 13:09

    Most web framework consider string representation as utf-8, so bytes in Python 3 (like Django, and Pyramid). In python3 needs to decode('utf-8') for body in:

    req = json.loads( request.body.decode('utf-8') )
    
    0 讨论(0)
  • 2021-01-11 13:27
    json_data = json.loads(request.read().decode('utf-8'))
    

    worked for me

    0 讨论(0)
提交回复
热议问题