In Node.js, how do I turn a string to a json?


Question

For example, a HTTP REST API just returned me a JSON, but of course it's a string right now. How can I turn it into a JSON?

1
126
4/27/2011 9:07:07 AM

Accepted Answer

You need to use this function.

JSON.parse(yourJsonString);

And it will return the object / array that was contained within the string.

285
4/27/2011 9:08:35 AM

use the JSON function >

JSON.parse(theString)

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon