toSource is non standard and works in the gecko engine only, so will not work in chrome, safari or IE.
toSource
See this SO question and answers.
It is not the same as toSource() but json2.js has JSON.stringify() which will convert a JavaScript object to JSON. This won't convert everything that .toSource() will. It doesn't for instance deal with functions.
toSource()
JSON.stringify()
.toSource()