简体   繁体   English

Parse.com说“寻找值的开头的无效字符'\\”

[英]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.

相关问题 Golang无效字符'b'寻找值的开始 - Golang invalid character 'b' looking for beginning of value Java中带有Parse.com请求的无效JSON - Invalid JSON with Parse.com Request in Java golang websocket.JSON.Receive无效字符'q'寻找值的开头 - golang websocket.JSON.Receive invalid character 'q' looking for beginning of value 从精读的HTTP中解组JSON:无效字符寻找值的开头 - Go unmarshalling JSON from compessed HTTP: invalid character looking for beginning of value 解组 JSON 返回错误:无效字符 '\\x1f' 寻找值的开头 - Unmarshalling JSON returns an error: invalid character '\x1f' looking for beginning of value “无效字符'u'寻找值的开始”使用golang开发的服务解析错误 - “invalid character 'u' looking for beginning of value”Parsing Error from an Service developed in golang JSON无效字符'}'正在寻找对象键字符串的开头 - JSON invalid character '}' looking for beginning of object key string Parse.com-解析long的值,而不是名称/标题 - Parse.com - Parsing the value of a long instead of the name/title json 格式无效,请检查。 原因:寻找对象键字符串开头的无效字符“a” - Invalid json format, please check. Reason: invalid character 'a' looking for beginning of object key string 将数组保存到Parse.com - Save array to Parse.com
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM