Reputation: 3559
On node.js, are JSON methods (parse, stringify) the same as Query Sting methods (parse, stringify) ?
Thank you.
Upvotes: 11
Views: 11557
Reputation:
Talking names. The query string methods return strings suitable for use in a URL query string. I. e., they are percent-escaped. That's not at all related to JSON.
Upvotes: 2
Reputation: 203494
Let's try:
var qs = require('querystring');
var obj = { 'foo' : '1 + 2' };
console.log(qs.stringify(obj));
// result: foo=1%20%2B%202
console.log(JSON.stringify(obj));
// result: {"foo":"1 + 2"}
So, no, they aren't :-)
Upvotes: 30