Possible Duplicate:
How to parse JSON in JavaScript
If you have JSON formatted like this:
{
"id": 10,
"user": {
"email": "example.com"
}
}
What is the standard way of parsing that into a JSON object in JavaScript? The use case is if a user is entering JSON into a textarea, parsing that out.
I started doing this but don't want to go down this road if there's already a robust/standard solution:
JSON.parse($('#the-textarea').val().replace(/^\s+/mg, '').replace(/\n/g, '')); // not quite right yet, still not parsable...