JSON.stringify()和JOSN.parse()
--------------------------------------------
JS呼叫到C#(cs)回傳解析-$.parseJSON ...好用
--------------------------------------------
$.ajax({
url: "WSAPI.asmx/XXXXX",
type: 'POST',
data: JSON.stringify({ "token": "1234" }),
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (rsp_data) {
var obj = $.parseJSON(rsp_data.d);
for (i = 0; i < obj.length; i++) {
console.log(obj [i].屬性);
}
}
});
--------------------------------------------
JS物件轉字串 --> JSON[parse]...暫時不用
--------------------------------------------
var str='{"name":"ju","age":"23"}';
var Object = JSON.parse(str);
Object.name = "ju"
Object.age = "23"
--------------------------------------------
JS字串轉物件 --> JSON.[stringify]...暫時不用
--------------------------------------------
JSON.stringify