Abbey Graebner
Abbey Graebner

Reputation: 2037

Un-JSON a String

Is there a function to un-JSON a String? I guessing it wouldn't be built in to JQuery, but could it be pulled off by writing a script that manipulates the String? I'm encountering this in the following.

I'm using the NYTimes API, but it doesn't support JSONP, so I'm trying to find alternatives to access it. I can't use a server-side proxy by virtue of the circumstances this script will be run in. I am trying YQL here, but the text returned is really messy. It is the JSON text as a String, and I can't use the JSON parsing capability. In other words, the text returned by YQL is the JSON of the JSON.

See this question for more context.

Upvotes: 1

Views: 795

Answers (3)

Adam Rackis
Adam Rackis

Reputation: 83358

If you don't want JSON.parse, but you're looking for a jquery way, then you can use

$.parseJSON(jsonString);

Upvotes: 2

user1027167
user1027167

Reputation: 4438

try

var myObject = eval('(' + myJSONtext + ')');

Upvotes: 0

DrStrangeLove
DrStrangeLove

Reputation: 11557

try using JSON.parse() method

Upvotes: 2

Related Questions