Wednesday, 7 September 2016

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




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



You need to use this function.




JSON.parse(yourJsonString);


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


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...