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

TIMEX picture TIMEX · Apr 27, 2011 · Viewed 191k times · Source

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?

Answer

Olical picture Olical · Apr 27, 2011

You need to use this function.

JSON.parse(yourJsonString);

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