It is worth mentioning that Anonymous's link (http://www.json.org/js.html) will point you in the right direction because the page also includes information about how to stringify a JavaScript data structure into JSON text:
A JSON stringifier goes in the opposite direction, converting JavaScript data structures into JSON text.
In particular, look for the link at the bottom of the page that points to an open source JSON parser and JSON stringifier.