3 ms·
Even I use JSON.parse() without knowing its benefit :3
by talnet 12y ago
Even I use JSON.parse() without knowing its benefit :3
- Havvy 12y agoJSON.parse takes a string of "JSON" and turns it into a JS object. It doesn't evaluate the string in a JS context at all, which is what eval() does. Some people have used eval() to do JSON parsing because JSON is a subset of JS, but if the user has any control into making malformed JSON, they could do so to create JS that can do anything the page can from the context of another user, otherwise known as Cross-Site-Scripting (XSS).