最佳答案
我一直对何时使用这两种解析方法感到困惑。
在我回显我的json_encoded数据并通过ajax检索它之后,我经常遇到关于何时应该使用JSON.stringify和JSON.parse的困惑。
我得到[object,object]
在我的console.log解析时和JavaScript对象时stringized。
$.ajax({
url: "demo_test.txt",
success: function(data) {
console.log(JSON.stringify(data))
/* OR */
console.log(JSON.parse(data))
//this is what I am unsure about?
}
});