How does django receive json data from post?

how to use js post to django data in django to receive
JS similar to this

str = "{"student":[{"number":"0","name":"a"}]}";
obj = JSON.parse(str);

look at the data in chrome like this

[student][0][number]:0
[student][0][name]:a

how do I receive it in django? Convert to dict?

Mar.13,2021

json.loads (request.body)


if request.method = = 'POST':

result = json.loads(request.body.decode()).get('ip')

request.body gets data of type bytes, which is first decoded to type str, that is, the result of request.body.decode () is a json string, then json.loads () is converted to a Python dictionary, and then the corresponding value

is obtained.

if you only receive POST data, use json.loads (request.POST) . Body contains the original byte type characters, so an error is reported. See django docs: https://docs.djangoproject.co.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e485c0-59cf8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e485c0-59cf8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?