如果数据已转义单引号,则无法在jqgrid中显示网格数据

如果数据已转义单引号,则无法在jqgrid中显示网格数据,jqgrid,Jqgrid,返回的JSON数据: { "page": "1", "total": 1, "records": "1", "rows": [ { "id": "10142", "cell": [ "10142", "Hello", "c:\\goodies\'", "singlequote

返回的JSON数据:

{
    "page": "1",
    "total": 1,
    "records": "1",
    "rows": [
        {
            "id": "10142",
            "cell": [
                "10142",
                "Hello",
                "c:\\goodies\'",
                "singlequoteissue" 
            ] 
        } 
    ]
}
带问题的字符串,即结尾为\'

"c:\\goodies\'"
jqgrid在没有单一报价的情况下运行良好

提前谢谢


Martin

使用从服务器接收的JSON数据是错误的。您可以验证任何JSON数据。上描述了哪些字符只能转义,哪些字符可以用反斜杠转义。列表中的“否”字符。因此,您的数据应该固定为

{
    "page": "1",
    "total": 1,
    "records": "1",
    "rows": [
        {
            "id": "10142",
            "cell": [
                "10142",
                "Hello",
                "c:\\goodies'",
                "singlequoteissue" 
            ] 
        } 
    ]
}

我建议您不要在服务器上实现手动JSON序列化,而是使用一些标准函数或库。在这种情况下,您将不会遇到此类问题。

发现问题时,JSON字符串无效,应改为c:\goodies'