未终止的字符串常量错误。将对象转换为json字符串时

时间:2016-01-25 16:33:00

标签: javascript jquery json hyperlink

我的json就像:

"ModelNo":"TEST 5","Weight":5,"ExportLevel":"Req'd","SafetyType":"UNDETERMINED"
var jsonString = JSON.stringify(rowObject);

我尝试过以下代码,但没有帮助:

jsonString.replace("'", "\\'");

我认为这个单引号是个问题。请帮忙。怎么逃避这个?

我的代码:

me.getHyperlinkColumn = function (cellvalue, options, rowObject) {       
    //var jsonString = JSON.parse(rowObject);        
    hyperLink = "<a href='#' id='hplinkactionUrl_" + options.rowId + "' onclick='" + options.colModel.CallMethod + "(" + options.rowId + "," + JSON.stringify(options) + "," + JSON.stringify(rowObject) + ")' style='text-decoration:underline; color:#3361b8;'>" + cellvalue + "</a>"
    return hyperLink;
}

0 个答案:

没有答案