jQuery.parseJSON 不适用于以下字符串:
({"stat":"OK","code":400,"data":[{"title":"Development Convention","event_type":false,"dates_and_times":[{"date":"28\/03\/2012","start_time":"10:00 AM","end_time":"10:00 AM"},{"date":"29\/03\/2012","start_time":"10:00 AM","end_time":"10:00 AM"},{"date":"30\/03\/2012","start_time":"12:00 PM","end_time":"12:00 PM"}],"description":"<p>This event will discuss different trends in development.<\/p>\n","featured_image":"<img src=\"http:\/\/mysite.com\/pesticide-free-organic-meal.jpg\" class=\"attachment-full wp-post-image\" alt=\"bavarian food plates with chicken and wine\" title=\"bavarian food plates with chicken and wine\" \/>","image_gallery":[{"url":"http:\/\/mysite.com","alt":false}]}]})
这是我接收数据的地方:
$.get(
api_url,
{ method: "list_events", venue_id: 73, event_date: 'null' },
function( data ) {
alert(data); // Shows the above string
var response = jQuery.parseJSON( data );
alert(1); // Doesn't appear
alert(response.stat); // Doesn't appear
}
);
任何人都可以提供任何关于为什么它可能不起作用的见解吗?我在 stackoverflow 上的其他地方读到反斜杠必须再次转义;\
用\\
using替换所有实例data = data.replace(/\\/g,"\\\\");
并不能解决问题。