How to JSON decode array elements in JavaScript?

javascript, json

Solution

var obj = jQuery.parseJSON('{"name":"John"}');
alert( obj.name === "John" );

See the jQuery API.

Problem

I have a JavaScript array that, among others, contains a URL. If I try to simply put the URL in the page (the array is in a project involving the Yahoo! Maps API) it shows the URL as it should be. But if I try to do a redirect or simply do an 'alert' on the link array element I get: function(){return JSON.encode(this);} As far as I see it this is because the browser does an JSON.encode when it renders the page, thus the link is displayed OK. I have tried several methods to make it redirect (that's what I want to do with the link) correctly (including the usage of 'eval') but with no luck. After following some suggestions I've run `eval('(' + jsonObject + ')')` but it still returns the same output. So how's this done ?

Original source