JSON.parse抛出意外的令牌

时间:2014-12-12 11:22:30

标签: json

为什么这个字符串会在JSON.parse

中抛出错误
[{"name":"listName","readonly":false,"value":"list"},{"name":"showHeader","readonly":true,"value":false},{"name":"showBorder","readonly":true,"value":false},{"name":"transparent","readonly":true,"value":true},{"name":"showTitle","readonly":false,"value":false},{"name":"showDesc","readonly":false,"value":false},{"name":"showMods","readonly":false,"value":false},{"name":"showTools","readonly":false,"value":true}]

这是代码。上面的字符串通过AJAX返回为widgetInstance.data

if ($scope.widgetInstance.widgetId == 6)
            {
                $scope.widgetData = JSON.parse($scope.widgetInstance.data);

            } else {
                $scope.widgetData = JSON.parse($scope.widgetInstance.dataSanitized);
            }

1 个答案:

答案 0 :(得分:0)

我尝试解析用RSA密钥解密的json对象时曾经遇到过同样的问题。由于填充,decrpytion导致字符串末尾的许多尾随“\ 0”。这导致json解析器错误。也许你遇到了同样的麻烦?