views:

35

answers:

0

How can I read an invalid Json returned string with Javascript (jQuery or not)? For example, the first FirstName will not be displayed as it contains an escaped character. So, I will get : undefined.

{
    "ListOfPersons":
        [
            {"Id":1,"FirstName containing doublequotes (ex: \") ":"Foo","LastName":"Bar"},
            {"Id":2,"FirstName":"Hello","LastName":"World"},
            {"Id":3,"FirstName":"Tanks","LastName":"Giving"},
        ]
}

I'm using this method:

var url = 'http://path/to/webservice.svc/ReturnTheList';
$.getJSON(url, function (data) {
    success: readData(data)
});

function readData(data){
    alert(data.ListOfPersons[0].FirstName);
}

Thanks,

Regards.