var jsData = {
id: 'E1',
firstname: 'Peter',
lastname: 'Funny',
project: { id: 'P1' },
activities: [
{ id: 'A1' },
{ id: 'A2' }
]};
var jsonData = JSON.stringify(jsData);
$('#click').click(function(){
$.ajax({
url: "test/",
type: "POST",
data: jsData,
dataType: "json",
success: function (data){
console.log(data);
},
error:function(){$('#text').html('FATAL_ERROR')}
})
})
这是 JS 代码,jsData 应该发送到服务器(Python)。在服务器上我得到类似 {'{id:'E1',firstname:'Peter',lastname:'Funny',project: { id:'P1'},activities: [{ id:'A1'},{ id: 'A2' }]};':''}
有没有一种聪明的方法可以将字符串“inner dict”从“outer dict”中取出?!