[英]Parse.com says “invalid character '\'' looking for beginning of value”
When I click finish import, Parse.com says "invalid character '\\'' looking for beginning of value". 当我单击“完成导入”时,Parse.com会显示“无效字符'\\”,以寻找值的开头”。 However, there is not a single character "\\" in my entire file.
但是,我的整个文件中没有单个字符“ \\”。 You can check it below.
您可以在下面查看。
Apparently, this is because of using single quotes instead of double quotes. 显然,这是因为使用单引号而不是双引号。 Can I use
"name": 'Samat',
instead of "name": "Samat"
? 我可以使用
"name": 'Samat',
代替"name": "Samat"
吗?
https://gist.github.com/samatdav/61db29a676da21dc4bbd https://gist.github.com/samatdav/61db29a676da21dc4bbd
The JSON format specification is very clear about this: String values must be enclosed in double quotes. JSON格式规范对此非常清楚:字符串值必须用双引号引起来。 Single quotes or unquoted values (other than true, false, null, numbers or nested object/array definitions) are not allowed.
不允许使用单引号或无引号的值(除true,false,null,数字或嵌套的对象/数组定义之外)。
JavaScript's internal object notation is much less strict in that regard, as it generally allows single-quoted strings. 在这方面,JavaScript的内部对象表示法不太严格,因为它通常允许使用单引号引起来的字符串。 However, JSON is only a subset of the original JavaScript object notation syntax.
但是,JSON只是原始JavaScript对象表示法语法的一个子集。
The error itself is telling you the invalid character is '
the single quote. 错误本身告诉您无效字符是
'
单引号。 It's just represented as a \\'
since they are using single quotes to enclose the invalid character the character must be escaped. 它只是表示为
\\'
因为它们使用单引号将必须转义的无效字符括起来。
"invalid character '\'' looking for beginning of value"
^ ^ notice the single quotes.
The issue in your gist is that single quotes are not valid representation of strings in JSON. 要点在于,单引号不是JSON中字符串的有效表示形式。
Note 注意
{
"foo": 'bar'
}
Yields the following error on JSONLint 在JSONLint上产生以下错误
Parse error on line 2:
{ "foo": 'bar'}
------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['
For anyone that might need this later. 对于以后可能需要它的任何人。 As
ipfs daemon --help
suggests, the cors domain can be set via 正如
ipfs daemon --help
建议的那样,可以通过以下方式设置cors域
>ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]'
which in Windows yields 在Windows中产生
Error: failed to unmarshal json. 错误:无法解组json。 invalid character '\\'' looking for beginning of value
无效字符'\\'寻找值的开始
The correct version should be 正确的版本应该是
>ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin "[\\"*\\"]"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.