#short
#javascript
#json
I have been confused over when to use these two parsing methods.
After I echo my json_encoded data and retrieve it back via ajax, I often run into confusion about when I should use JSON.stringify and JSON.parse.
I get [object,object] in my console.log when parsed and a JavaScript object when stringified.
$.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?
}
});
Watch video javascript - Difference between JSON.stringify and JSON.parse online without registration, duration hours minute second in high quality. This video was added by user Code Samples 25 June 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 180 once and liked it 3 people.