我想在django视图中获取和解析json。如何在Django中执行JSON处理程序
Requst模板:
var values = {};
$("input[name^='param']").each(function() {
values[$(this).attr("name")] = $(this).val();
});
$.ajax
({
type: "POST",
url: page,
contentType: 'application/json; charset=utf-8',
async: false,
processData: false,
data: $.toJSON(values),
success: function (resp) {
console.log(resp);
}
});
鉴于:
import json
...
req = json.loads(request.body)
return HttpResponse(req)
它给我的错误:
the JSON object must be str, not 'bytes'
我做什么了?
你能表现出*** request.body的内容***在* *查看**? – AlvaroAV 2014-09-22 07:42:32
{ “参数1”: “fdgdf3”, “参数2”: “GGGGG”, “参数3”: “”, “param4”: “”} – bdhvevhvonof 2014-09-22 07:45:57