开发者

Grid data cannot be displayed in jqgrid if data has escaped single quote

Returned JSON data:

{
    "page": "1",
    "total": 1,
    "records": "1",
    "rows": [
        {
            "id": "101开发者_如何学JAVA42",
            "cell": [
                "10142",
                "Hello",
                "c:\\goodies\'",
                "singlequoteissue" 
            ] 
        } 
    ]
}

String with problem (i.e. \' at the end)

"c:\\goodies\'"

jqgrid works fine without the single quote ...

Thanks in advance.

Martin


The JSON data which use receive from the server are wrong. You can validate any JSON data here. On the http://www.json.org/ is described which characters must be escaped (only " and ) and which can be escaped with the backslash. The ' character is in no from the lists. So you data should be fixed to

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

I recommend you don't implement manual JSON serialization on the server and use some standard function (or library). In the case you will not have such problems.


Problem found, the JSON string is not valid should be "c:\goodies'" instead

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜