javascript - Difference between JSON.stringify and JSON.parse -
i have been confused on when use these 2 parsing methods.
after echo json_encoded data , retrieve via ajax, run confusion when should use json.stringify , json.parse.
i [object,object]
in console.log when parsed , javascript object when stringified.
$.ajax({ url: "demo_test.txt", success: function(data) { console.log(json.stringify(data)) /* or */ console.log(json.parse(data)) //this unsure about? } });
json.stringify
turns javascript object json text , stores json text in string.
json.parse
turns string of json text javascript object.
Comments
Post a Comment