Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 我在一些wordpress插件代码中有一个JSON.parse语法错误_Javascript_Json_Wordpress - Fatal编程技术网

Javascript 我在一些wordpress插件代码中有一个JSON.parse语法错误

Javascript 我在一些wordpress插件代码中有一个JSON.parse语法错误,javascript,json,wordpress,Javascript,Json,Wordpress,我是JSON新手,在一小段代码中遇到了一个错误 代码是: this.json = function() { return this.text().then(json.parse); }; 错误是: SyntaxError: JSON.parse: unexpected character at line 1 column 3 of the JSON data 有人知道问题出在哪里吗?不太清楚您试图解析的JSON是什么。您的代码建议thi

我是JSON新手,在一小段代码中遇到了一个错误

代码是:

this.json = function() {
                return this.text().then(json.parse);
            };
错误是:

SyntaxError: JSON.parse: unexpected character at line 1 column 3 of the JSON data

有人知道问题出在哪里吗?

不太清楚您试图解析的JSON是什么。您的代码建议
this.text()
返回一个承诺,您希望将文本导入
JSON.parse
函数。看起来一切正常


使用
this.text()
的输出进行更新,我们可以看到JSON中的无效内容。

由于错误,我很难获得任何输出。我知道它正在创建错误的唯一方法是,它显示在inspect控制台中。如果您对获取输出有任何建议,我们将不胜感激。您能否将代码段
this.text().then(json.parse)
替换为
this.text().then(console.log)
?这应该会将JSON输出到控制台,但没有输出任何内容,因此我假设在wordpress代码的其他地方产生了JSON.parse错误。虽然只有在触发此特定插件时才会触发此错误。插件是“Usernoise”,这是一个旧的反馈插件(作者不再提供支持),当我搜索插件代码时,它只有一个JSON实例。parseYeah,没有它试图解析的实际JSON,我无法找出错在哪里我已经深入研究了一点,我不确定我是否做了正确的事情,我查看了“网络”面板和一个method=POST,type=json,Cause=fetch,file=当我单击它时,它会将以下内容输出到浏览器: