字符串返回到JSONPjQuery调用时获取无效JSON错误

字符串返回到JSONPjQuery调用时获取无效JSON错误,json,c#-2.0,jsonp,Json,C# 2.0,Jsonp,我有下面的JSONP完整字符串,它从我的aspx页面返回到客户端 "processjsonp({\"result\": [\"CreateCityKeys\", \"Keyword -Spokane already exists in City\r\nKeyword -Anchorage already exists in City\r\nKeyword -Fairbanks already exists in City\r\nKeyword -Bellingham already exists

我有下面的JSONP完整字符串,它从我的aspx页面返回到客户端

"processjsonp({\"result\": [\"CreateCityKeys\", \"Keyword -Spokane already exists in City\r\nKeyword -Anchorage already exists in City\r\nKeyword -Fairbanks already exists in City\r\nKeyword -Bellingham already exists in City\r\nKeyword -Juneau already exists in City\r\nKeyword -Boise already exists in City\r\nKeyword -Victoria already exists in City\r\nKeyword -Kelowna already exists in City\r\nKeyword -Eugene already exists in City\r\nKeyword -Medford already exists in City\r\nKeyword -Tucson already exists in City\r\nKeyword -Walla Walla already exists in City\r\nKeyword -Wenatchee already exists in City\r\nKeyword -Pasco already exists in City\r\nKeyword -Pullman already exists in City\r\nKeyword -Redmond already exists in City\r\nKeyword -Yakima already exists in City\r\nKeyword -Ketchikan already exists in City\r\nKeyword -Kauai Island already exists in City\r\nKeyword -Kona already exists in City\r\nKeyword -Kahului already exists in City\r\n\"]})"
我知道该错误一定是由于\r\n介于两者之间,请建议将其删除

谢谢

硕士


编辑:Error-JSONP parser Error

您的JSON语法不正确,您可以将\“替换为just”并检查关于此的解析器字符串限制您的JSON语法不正确,您可以将\“替换为just”并检查关于此的解析器字符串限制示例服务器响应:

json = {"result": ["CreateCityKeys", "Keyword -Spokane already exists in City", "Keyword -Anchorage already exists in City", "Keyword -Fairbanks already exists in City", "Keyword -Bellingham already exists in City", "Keyword -Juneau already exists in City", "Keyword -Boise already exists in City", "Keyword -Victoria already exists in City", "Keyword -Kelowna already exists in City", "Keyword -Eugene already exists in City", "Keyword -Medford already exists in City", "Keyword -Tucson already exists in City", "Keyword -Walla Walla already exists in City", "Keyword -Wenatchee already exists in City", "Keyword -Pasco already exists in City", "Keyword -Pullman already exists in City", "Keyword -Redmond already exists in City", "Keyword -Yakima already exists in City", "Keyword -Ketchikan already exists in City", "Keyword -Kauai Island already exists in City", "Keyword -Kona already exists in City", "Keyword -Kahului already exists in City",]}
x = jQuery.parseJSON( json )
$.each(x.result, function(i, item){
    document.write('<p>' + item + '</p>');
});
jquery演示:

json = {"result": ["CreateCityKeys", "Keyword -Spokane already exists in City", "Keyword -Anchorage already exists in City", "Keyword -Fairbanks already exists in City", "Keyword -Bellingham already exists in City", "Keyword -Juneau already exists in City", "Keyword -Boise already exists in City", "Keyword -Victoria already exists in City", "Keyword -Kelowna already exists in City", "Keyword -Eugene already exists in City", "Keyword -Medford already exists in City", "Keyword -Tucson already exists in City", "Keyword -Walla Walla already exists in City", "Keyword -Wenatchee already exists in City", "Keyword -Pasco already exists in City", "Keyword -Pullman already exists in City", "Keyword -Redmond already exists in City", "Keyword -Yakima already exists in City", "Keyword -Ketchikan already exists in City", "Keyword -Kauai Island already exists in City", "Keyword -Kona already exists in City", "Keyword -Kahului already exists in City",]}
x = jQuery.parseJSON( json )
$.each(x.result, function(i, item){
    document.write('<p>' + item + '</p>');
});
x=jQuery.parseJSON(json)
$。每个(x.结果,函数(i,项){
文件。写(“”+项+”

”); });
服务器响应示例:

json = {"result": ["CreateCityKeys", "Keyword -Spokane already exists in City", "Keyword -Anchorage already exists in City", "Keyword -Fairbanks already exists in City", "Keyword -Bellingham already exists in City", "Keyword -Juneau already exists in City", "Keyword -Boise already exists in City", "Keyword -Victoria already exists in City", "Keyword -Kelowna already exists in City", "Keyword -Eugene already exists in City", "Keyword -Medford already exists in City", "Keyword -Tucson already exists in City", "Keyword -Walla Walla already exists in City", "Keyword -Wenatchee already exists in City", "Keyword -Pasco already exists in City", "Keyword -Pullman already exists in City", "Keyword -Redmond already exists in City", "Keyword -Yakima already exists in City", "Keyword -Ketchikan already exists in City", "Keyword -Kauai Island already exists in City", "Keyword -Kona already exists in City", "Keyword -Kahului already exists in City",]}
x = jQuery.parseJSON( json )
$.each(x.result, function(i, item){
    document.write('<p>' + item + '</p>');
});
jquery演示:

json = {"result": ["CreateCityKeys", "Keyword -Spokane already exists in City", "Keyword -Anchorage already exists in City", "Keyword -Fairbanks already exists in City", "Keyword -Bellingham already exists in City", "Keyword -Juneau already exists in City", "Keyword -Boise already exists in City", "Keyword -Victoria already exists in City", "Keyword -Kelowna already exists in City", "Keyword -Eugene already exists in City", "Keyword -Medford already exists in City", "Keyword -Tucson already exists in City", "Keyword -Walla Walla already exists in City", "Keyword -Wenatchee already exists in City", "Keyword -Pasco already exists in City", "Keyword -Pullman already exists in City", "Keyword -Redmond already exists in City", "Keyword -Yakima already exists in City", "Keyword -Ketchikan already exists in City", "Keyword -Kauai Island already exists in City", "Keyword -Kona already exists in City", "Keyword -Kahului already exists in City",]}
x = jQuery.parseJSON( json )
$.each(x.result, function(i, item){
    document.write('<p>' + item + '</p>');
});
x=jQuery.parseJSON(json)
$。每个(x.结果,函数(i,项){
文件。写(“”+项+”

”); });
返回客户端时,这只是一个parsor错误返回客户端时,这只是一个parsor错误OK那么,由于此字符串是使用StringBuilder生成的,因此如何在新行中显示上述所有文本。AppendLine,请建议您拆分最长的字符串,然后使用foreach打印其ORRY,检查这个例子:{“结果”:[“CreateCityKeys”,“0xxxxxx”,“1xx”,…“nxxx”]},然后做一些类似于foerach(item:jsonX.result){print item}的事情,好的,那么我如何在新行中显示以上所有文本,因为这个字符串是使用StringBuilder.AppendLine生成的,请建议您可以拆分最长的字符串,然后使用foreach来打印它。请检查以下示例:{“结果”:[“CreateCityKeys”,“0xxxxxx”,“1xxxx”,…“nxxx”]},然后只需执行类似于foerach(item:jsonX.result){print item}的操作即可,我不想只打印结果[1]中的所有字符串,因为我不想打印“CreateCityKeys”,而且由于它是动态创建的,所以制作上述格式字符串也不容易,请建议另一种方法告诉我们您真正想要的是什么…,只是第二项(表示结果[1]),只需替换$each。。。。与文件一起写入(x.result[1]);可以吗?Hwy Toloo,我不想打印所有字符串,只打印结果[1],因为我不想打印“CreateCityKeys”,而且由于它是动态创建的,所以制作上述格式字符串也不容易,请建议另一种方法告诉我们您真正想要的是什么…,只是第二项(表示结果[1]),只需替换$each。。。。与文件一起写入(x.result[1]);可以吗?