在嵌套对象上使用JSON.stringify()的正确方法是什么?我收到来自API调用一个坏的请求预计JSON字符串:JSON.stringify() - 嵌套对象
testData = {"credentials": {"user": "[email protected]", "password": "testpassword", "country": "us"}};
当我查看postDasta:
"{"credentials": {"user": "[email protected]", "password": "testpassword", "country": "us"}}";
$.ajax({
...
data: JSON.stringify(testData),
...
});
感谢,
Ĵ
您是否尝试过将对象传递给数据而不进行字符串化?我不记得数据参数期望一个字符串。据我所知,它要么是一个对象,要么是一个字符串来代替get请求。 – Daedalus