json returned from flickr api not getting parsed

Viewed 751

I am trying to consume flickr api and requesting data in json format from a node.js server. I am providing nojsoncallback=1 so that returned json is not wrapped inside a jsonp callback. Here is the url http://api.flickr.com/services/feeds/photos_public.gne?format=json&nojsoncallback=1.

Json returned is not properly formatted and JSON.parse is unable to parse it. If I don't pass nojsoncallback query param and eval the response which calls jsonFlickrFeed function, it gets evaled properly and I get the object. I also notice that the Content-type header in the response is application/x-javascript; charset=utf-8. I suspect that the special characters are double escaped in returned response.

I don't want to eval, what can I do to convert the response correctly into a string and then parse it?

By the way here is the gist with simplest use case. No modules, no middlewares.

0 Answers
Related