How to use JSON2 in Node.js How to use JSON2 in Node.js json json

How to use JSON2 in Node.js


json2 checks for the existence of the JSON object before it overrides it. To use json2 you'd need to do something like

var oldJSON = JSON;JSON = undefined;require('json2');JSON.stringify = oldJSON.stringify; // assuming you want builtin stringify

But note that the JSON implementation in json2.js is not 100% correct, is much slower than the builtin impl, and is less secure.