a = "{'sentiments': [['1485925200000', '0.0636363636364']]}"
// typeof(a) returns string
尝试使用JSON.parse(a)将此字符串转换为角度上的json对象。但是,我得到了一个错误。
SyntaxError: Unexpected token ' in JSON at position 1
at JSON.parse (<anonymous>)
我收到了很多错误,不知道从哪里开始。 错误消息 > webpack
[webpack-cli] Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
- configuration.module.rules[1] should be one of these:
["..." | object { assert?, compiler?, dependency?, desc
因此,我有一个js对象,其中包含以下示例键值对。
var serial = {
open: function(a, b) {
do something..
},
close: function (a,b) {
do something
}
}
如上所述,键的值是js函数。由于一些要求,我必须将整个对象转换为字符串。我使用以下代码将其转换为字符串:
var json = JSON.stringify(window.serial, function(key, value) {
if (typeof value === 'function
我以前设法用java代码解析json url,但现在需要将它迁移到javascript。当我使用JavaScript进行解析时,出现了语法错误:意外令牌
SyntaxError: Unexpected token i in JSON at position 2
at JSON.parse (<anonymous>)
at success (homeCtrl.js:1060)
at processQueue (ionic.bundle.js:29127)
at ionic.bundle.js:29143
at Scope.$eval (ionic.bundle.js:30395)
a