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?
Asked
Active
Viewed 2.3e+01k times
162
-
4If you have fixed your problem please accept one of the answers below. If not, let us know whats wrong and we can try to help. – Olical Apr 27 '11 at 09:31
-
9It's not called "a JSON." JSON is a string format. You want to turn a JSON-formatted string into a JavaScript object. Read this for more details: http://benalman.com/news/2010/03/theres-no-such-thing-as-a-json/ – Matt Ball Apr 27 '11 at 13:29
2 Answers
348
You need to use this function.
JSON.parse(yourJsonString);
And it will return the object / array that was contained within the string.

Olical
- 39,703
- 12
- 54
- 77
48
use the JSON function >
JSON.parse(theString)

Deepak Mahakale
- 22,834
- 10
- 68
- 88

neebz
- 11,465
- 7
- 47
- 64