I'm parsing an API in NodeJS that returns this data, as a string:
{
"query": {
"count": 1,
"created": "2013-12-09T08:05:21Z",
"lang": "en-US",
"results": {
"rate": {
"id": "GBPEUR",
"Name": "GBP to EUR",
"Rate": "1.1938",
"Date": "12/9/2013",
"Time": "3:05am",
"Ask": "1.194",
"Bid": "1.1936"
}
}
}
}
I'd like to convert this into a javascript Object so that I can parse it like var rate = obj.query.results.rate.Rate
.
I've tried using Node's QueryString Parse() but this doesn't work as expected, and eval()
doesn't work either. How can I achieve this (obviously preferably without using eval()
)?