Javascript JSON.parse exptected'';或';}';有什么想法吗?两者都不';行不通

Javascript JSON.parse exptected'';或';}';有什么想法吗?两者都不';行不通,javascript,json,Javascript,Json,JSON.parse和eval函数都出错。我用什么方法验证了JSON <script type="text/javascript"> var obj = JSON.parse('{ "defaults": { "recordtext": "View", "emptyrecords": "No records to view", "loadtext": "Loading...", "pgtext": "Page" }, "search": { "caption": "Search.

JSON.parse和eval函数都出错。我用什么方法验证了JSON

<script type="text/javascript"> 

var obj = JSON.parse('{ "defaults": { "recordtext": "View", "emptyrecords": "No records to view", "loadtext": "Loading...", "pgtext": "Page" }, "search": { "caption": "Search...", "Find": "Find", "Reset": "Reset", "odata": [ "equal", "not equal", "less", "less or equal", "greater", "greater or equal", "begins with", "does not begin with", "is in", "is not in", "ends with", "does not end with", "contains", "does not contain" ], "groupOps": [ { "op": "AND", "text": "all" }, { "op": "OR", "text": "any" } ], "matchText": " match", "rulesText": " rules" }, "edit": { "addCaption": "Add Record", "editCaption": "Edit Record", "bSubmit": "Submit", "bCancel": "Cancel", "bClose": "Close", "saveData": "Data has been changed! Save changes?", "bYes": "Yes", "bNo": "No", "bExit": "Cancel", "msg": { "required": "Field is required", "number": "Please, enter valid number", "minValue": "value must be greater than or equal to ", "maxValue": "value must be less than or equal to", "email": "is not a valid e-mail", "integer": "Please, enter valid integer value", "date": "Please, enter valid date value", "url": "is not a valid URL. Prefix required (\"http://\" or \"https://\")", "nodefined": " is not defined!", "novalue": " return value is required!", "customarray": "Custom function should return array!", "customfcheck": "Custom function should be present in case of custom checking!" } }, "view": { "caption": "View Record", "bClose": "Close" }, "del": { "caption": "Delete", "msg": "Delete selected record(s)?", "bSubmit": "Delete", "bCancel": "Cancel" }, "nav": { "edittext": "", "edittitle": "Edit selected row", "addtext": "", "addtitle": "Add new row", "deltext": "", "deltitle": "Delete selected row", "searchtext": "", "searchtitle": "Find records", "refreshtext": "", "refreshtitle": "Reload Grid", "alertcap": "Warning", "alerttext": "Please, select row", "viewtext": "", "viewtitle": "View selected row" }, "col": { "caption": "Select columns", "bSubmit": "Ok", "bCancel": "Cancel" }, "errors": { "errcap": "Error", "nourl": "No url is set", "norecords": "No records to process", "model": "Length of colNames <> colModel!" }, "formatter": { "integer": { "thousandsSeparator": " ", "defaultValue": "0" }, "number": { "decimalSeparator": ".", "thousandsSeparator": " ", "decimalPlaces": 2, "defaultValue": "0.00" }, "currency": { "decimalSeparator": ".", "thousandsSeparator": " ", "decimalPlaces": 2, "prefix": "", "suffix": "", "defaultValue": "0.00" }, "date": { "dayNames": [ "Sun", "Mon", "Tue", "Wed", "Thr", "Fri", "Sat", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], "monthNames": [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], "AmPm": [ "am", "pm", "AM", "PM" ], "srcformat": "Y-m-d", "newformat": "m/d/Y", "masks": { "ISO8601Long": "Y-m-d H:i:s", "ISO8601Short": "Y-m-d", "ShortDate": "n/j/Y", "LongDate": "l, F d, Y", "FullDateTime": "l, F d, Y g:i:s A", "MonthDay": "F d", "ShortTime": "g:i A", "LongTime": "g:i:s A", "SortableDateTime": "Y-m-d\\TH:i:s", "UniversalSortableDateTime": "Y-m-d H:i:sO", "YearMonth": "F, Y" }, "reformatAfterEdit": false }, "baseLinkUrl": "", "showAction": "", "target": "", "checkbox": { "disabled": true }, "idName": "id" }, "emptyrecords": "test" }');
var obj2 = eval ( '(' + '{ "defaults": { "recordtext": "View", "emptyrecords": "No records to view", "loadtext": "Loading...", "pgtext": "Page" }, "search": { "caption": "Search...", "Find": "Find", "Reset": "Reset", "odata": [ "equal", "not equal", "less", "less or equal", "greater", "greater or equal", "begins with", "does not begin with", "is in", "is not in", "ends with", "does not end with", "contains", "does not contain" ], "groupOps": [ { "op": "AND", "text": "all" }, { "op": "OR", "text": "any" } ], "matchText": " match", "rulesText": " rules" }, "edit": { "addCaption": "Add Record", "editCaption": "Edit Record", "bSubmit": "Submit", "bCancel": "Cancel", "bClose": "Close", "saveData": "Data has been changed! Save changes?", "bYes": "Yes", "bNo": "No", "bExit": "Cancel", "msg": { "required": "Field is required", "number": "Please, enter valid number", "minValue": "value must be greater than or equal to ", "maxValue": "value must be less than or equal to", "email": "is not a valid e-mail", "integer": "Please, enter valid integer value", "date": "Please, enter valid date value", "url": "is not a valid URL. Prefix required (\"http://\" or \"https://\")", "nodefined": " is not defined!", "novalue": " return value is required!", "customarray": "Custom function should return array!", "customfcheck": "Custom function should be present in case of custom checking!" } }, "view": { "caption": "View Record", "bClose": "Close" }, "del": { "caption": "Delete", "msg": "Delete selected record(s)?", "bSubmit": "Delete", "bCancel": "Cancel" }, "nav": { "edittext": "", "edittitle": "Edit selected row", "addtext": "", "addtitle": "Add new row", "deltext": "", "deltitle": "Delete selected row", "searchtext": "", "searchtitle": "Find records", "refreshtext": "", "refreshtitle": "Reload Grid", "alertcap": "Warning", "alerttext": "Please, select row", "viewtext": "", "viewtitle": "View selected row" }, "col": { "caption": "Select columns", "bSubmit": "Ok", "bCancel": "Cancel" }, "errors": { "errcap": "Error", "nourl": "No url is set", "norecords": "No records to process", "model": "Length of colNames <> colModel!" }, "formatter": { "integer": { "thousandsSeparator": " ", "defaultValue": "0" }, "number": { "decimalSeparator": ".", "thousandsSeparator": " ", "decimalPlaces": 2, "defaultValue": "0.00" }, "currency": { "decimalSeparator": ".", "thousandsSeparator": " ", "decimalPlaces": 2, "prefix": "", "suffix": "", "defaultValue": "0.00" }, "date": { "dayNames": [ "Sun", "Mon", "Tue", "Wed", "Thr", "Fri", "Sat", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], "monthNames": [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], "AmPm": [ "am", "pm", "AM", "PM" ], "srcformat": "Y-m-d", "newformat": "m/d/Y", "masks": { "ISO8601Long": "Y-m-d H:i:s", "ISO8601Short": "Y-m-d", "ShortDate": "n/j/Y", "LongDate": "l, F d, Y", "FullDateTime": "l, F d, Y g:i:s A", "MonthDay": "F d", "ShortTime": "g:i A", "LongTime": "g:i:s A", "SortableDateTime": "Y-m-d\\TH:i:s", "UniversalSortableDateTime": "Y-m-d H:i:sO", "YearMonth": "F, Y" }, "reformatAfterEdit": false }, "baseLinkUrl": "", "showAction": "", "target": "", "checkbox": { "disabled": true }, "idName": "id" }, "emptyrecords": "test" }' + ')');

</script>  

var obj=JSON.parse(“{”默认值“:{”记录文本“:”查看“,”清空记录“:”无记录可查看“,”加载文本“:”加载“,”pgtext“:”页面“}”,搜索“:{”标题“:”搜索“,”查找“,”重置“:”重置“,”odata“:[”相等“,”不相等“,”更少或相等“,”更大“,”更大或相等“,”以开头“,”不以“,”开头“,”在”“,”不在“,”以“,”以“,”不以“,”包含“,”不包含“,”groupOps:“[{”op:”和“,”文本“:”所有“},{”op:”或“,”文本“:”任何“}],”匹配文本“:”匹配“,”规则文本“:”规则“}”,编辑“:{”添加记录“,”编辑标题“:”编辑记录“,”提交“,”取消“,”关闭“,”保存数据”:“数据已更改!保存更改?”,“是”:“是”,“bNo”:“否”,“bExit”:“取消”,“msg”:{“必需”:“字段是必需的”,“数字”:“请输入有效数字”,“minValue”:“值必须大于或等于”,“maxValue”:“值必须小于或等于”,“电子邮件”:“不是有效电子邮件”,“整数”:“请输入有效的整数值”,“日期”:“请输入有效的日期值”,“url”:“不是有效的url。需要前缀(\“http://\”或\“https://\”),“节点定义”:“未定义!”,“novalue”:“需要返回值!”,“customarray”:“自定义函数应返回数组!”,“customfcheck”:”在进行自定义检查时,应提供自定义函数!}},“查看”:{“标题”:“查看记录”,“关闭”},“删除”:{“标题”:“删除”,“消息”:“删除选定记录”;“bSubmit”:“删除”,“取消”:“取消”},“导航”:{“编辑文本”:“编辑选定行”,“添加文本”:“添加新行”,“添加文本”:”“,”deltitle“:”删除所选行“,”searchtext“:”searchtitle“:”查找记录“,”刷新文本“:”刷新标题“,”重新加载网格“,”alertcap“:”警告“,”alerttext“:”请,选择行“,”viewtext“,”viewtitle“:”查看所选行“,”列“:”{”标题“:”选择列“,”B提交“:”确定“,”取消“,”取消“,”错误“:{”errcap“错误”,“nourl”:“未设置url”,“norecords”:“无需处理的记录”,“model”:“colNames colModel!”的长度,“formatter”:{“integer”:{“thousandsSeparator”:“defaultValue”:“0”},“number”:{“decimalSeparator”:“thousandsSeparator”:“decimalPlaces”:2,“defaultValue”:“0.00”},“currency”:{“decimalSeparator”:”千位数字“:”小数点“:”2,“前缀“:”后缀“:”默认值“:”0.00“}”,日期“{”日名“:[“太阳”、“星期一”、“星期二”、“星期五”、“星期一”、“星期二”、“星期三”、“星期四”、“星期五”、“星期六”],”月日“:[“一月”、“二月”、“三月”、“四月”、“五月”、“六月”、“七月”、“八月”、“九月”、“十月”、“十一月”12月、1月、2月、3月、4月、5月、6月、7月、8月、9月、10月、11月、12月、AmPm:[“上午”、“下午”、“上午”、“下午”、“下午”]、“SRC格式”:“Y-m-d”、“新格式”:“m/d/Y”、“掩码”:{“ISO8601Long”:“Y-m-d H:i:s”、“ISO8601Short”:“Y-m-d”、“短日期”:“n/j/Y”、“长日期”:“l、F-d、Y”、“完整日期”:l、 fd,yg:i:sa,MonthDay:“fd”,“ShortTime:“g:ia”,“LongTime:“g:i:sa”,“SortableDateTime:“Y-m-d\\TH:i:s”,“UniversalSortableDateTime:“Y-m-d H:i:sO”,“YearMonth:”F,Y“},“ReformataAfterEdit:”false“,“baseLinkUrl:“showAction:”目标“,”复选框:{“disabled:”true:“idName:”id“,“emptyrecords:”test“}”;
var obj2=eval(“(“+”{“默认值”):{“记录文本”:“查看”,“清空记录”:“无需查看记录”,“加载文本”:“加载…”,“pgtext”:“页面”},“搜索”:“{“标题”:“搜索…”,“查找”:“查找”,“重置”:“重置”,“odata”:[“相等”,“不相等”,“更少”,“更少或相等”,“更大”,“更大或相等”,“以开始”,“不以“,”位于“,”不在“,”结束于“,”不结束于“,”包含“,”不包含“,”组操作“:[{”操作“:”和“,”文本“:”所有“},{”操作“:”或“,”文本“:”任何“}”,“匹配文本“:”匹配“,”规则文本“:”规则“}”,编辑“:{”添加标题“,”编辑标题“,”编辑记录“,”提交“,”取消“,”关闭“,”saveData:“数据已更改!保存更改?”,“是”:“是”,“bNo:“否”,“bExit:“取消”,“msg:{”必需“:“字段是必需的”,“数字”:“请输入有效数字”,“minValue:“值必须大于或等于”,“maxValue:“值必须小于或等于”,“电子邮件:“不是有效电子邮件”,“整数”:”请输入有效的整数值,“日期”:“请输入有效的日期值”,“url”:“不是有效的url。需要前缀(\“http://\”或\“https://\”),“节点定义”:“未定义!”,“novalue”:“需要返回值!”,“customarray”:“自定义函数应返回数组!”,“customfcheck”:在进行自定义检查时,应提供自定义函数!}},“查看”:{“标题”:“查看记录”,“关闭”},“删除”:{“标题”:“删除”,“消息”:“删除选定记录”;“bSubmit”:“删除”,“取消”:“取消”},“导航”:{“编辑文本”:“编辑选定行”,“添加文本”:“添加新行”,“添加文本”:”“,”deltitle“:”删除所选行“,”searchtext“:”searchtitle“:”查找记录“,”刷新文本“:”刷新标题“,”重新加载网格“,”alertcap“:”警告“,”alerttext“:”请,选择行“,”viewtext“,”viewtitle“:”查看所选行“,”列“:”{”标题“:”选择列“,”B提交“:”确定“,”取消“,”取消“,”错误“:{”errcap“错误”,“nourl”:“未设置url”,“norecords”:“无需处理的记录”,“model”:“colNames colModel!”的长度,“formatter”:{“integer”:{“thousandsSeparator”:“defaultValue”:“0”},“number”:{“decimalSeparator”:“thousandsSeparator”:“decimalPlaces”:2,“defaultValue”:“0.00”},“currency”:{“decimalSeparator”:”千分位“,”十进制
JSON.parse('{ "fails" : "\"http://\" or \"https://\"" }')
JSON.parse('{ "passes" : "\\"http://\\" or \\"https://\\"" }')
var xx = <that-thing-you-validated>;
var yy = {text: "hello \"world\""};
console.log(JSON.stringify(yy));
// output: "{"text":"hello \"world\""}"
console.log('{"text":"hello \"world\""}');
// output: {"text":"hello "world""}
console.log('{"text":"hello \\"world\\""}');
// output: {"text":"hello \"world\""}
JSON.parse('{"text":"hello \\"world\\""}');
// output: Object