JSON解析Windows文件路径
JSON parse Windows file path
我想在我的 remote-ftp Atom 配置中指定一个 windows 文件路径来引用我的私钥,但我遇到了一些解析问题。这是我的配置:
{
"protocol": "sftp",
"host": "somehost.com",
"port": 22,
"user": "haha",
"pass": "testpass",
"promptForPass": false,
"remote": "/",
"local": "",
"agent": "",
"privatekey": "C:\Users\haha\Documents\Keys\test_private_key.ppk",
"passphrase": "",
"hosthash": "",
"ignorehost": true,
"connTimeout": 10000,
"keepalive": 10000,
"keyboardInteractive": false,
"keyboardInteractiveForPass": false,
"remoteCommand": "",
"remoteShell": "",
"watch": [],
"watchTimeout": 500
}
出现错误:
解析错误:"privatekey": "C:\Users\haha\Docum
所以知道我如何转义 Windows 文件路径以进行 JSON 解析吗?
您的 JSON 无效,因为每个 spec.
需要转义反斜杠
A string is a sequence of zero or more Unicode characters, wrapped in double quotes, using backslash escapes
因此,privateKey
的值应该是"C:\Users\haha\Documents\Keys\test_private_key.ppk"
。
我想在我的 remote-ftp Atom 配置中指定一个 windows 文件路径来引用我的私钥,但我遇到了一些解析问题。这是我的配置:
{
"protocol": "sftp",
"host": "somehost.com",
"port": 22,
"user": "haha",
"pass": "testpass",
"promptForPass": false,
"remote": "/",
"local": "",
"agent": "",
"privatekey": "C:\Users\haha\Documents\Keys\test_private_key.ppk",
"passphrase": "",
"hosthash": "",
"ignorehost": true,
"connTimeout": 10000,
"keepalive": 10000,
"keyboardInteractive": false,
"keyboardInteractiveForPass": false,
"remoteCommand": "",
"remoteShell": "",
"watch": [],
"watchTimeout": 500
}
出现错误:
解析错误:"privatekey": "C:\Users\haha\Docum
所以知道我如何转义 Windows 文件路径以进行 JSON 解析吗?
您的 JSON 无效,因为每个 spec.
需要转义反斜杠A string is a sequence of zero or more Unicode characters, wrapped in double quotes, using backslash escapes
因此,privateKey
的值应该是"C:\Users\haha\Documents\Keys\test_private_key.ppk"
。