Convert JS object to JSON string

All current browsers have native JSON support built in. So as long as you’re not dealing with prehistoric browsers like IE6/7 you can do it just as easily as that:

var j = {
  "name": "binchen"
};
console.log(JSON.stringify(j));

Leave a Comment