【发布时间】:2018-01-31 07:40:34
【问题描述】:
这可能是一个简单的问题,但我正在努力弄清楚 jq 如何处理元素中的空格。 (以下是windows powershell)
PS C:\Users\Home> "{}" | jq ".mytest.path = """"success"""""
{
"mytest": {
"path": "success"
}
}
现在,我想让“我的测试”成为两个单独的词。我想要的输出是
{
"my - test": {
"path": "success"
}
}
我会使用什么查询?我尝试了以下方法:
PS C:\Users\Home> "{}" | jq ".""my - test"".path = """"success"""""
jq : jq: error: Could not open file test.path = "success": Invalid argument
At line:1 char:8
+ "{}" | jq ".""my - test"".path = """"success"""""
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (jq: error: Coul...nvalid argument:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
PS C:\Users\Home> "{}" | jq --raw-output ".""my test"".path = """"success"""""
jq : jq: error: Could not open file test.path = "success": Invalid argument
At line:1 char:8
+ "{}" | jq --raw-output ".""my test"".path = """"success"""""
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (jq: error: Coul...nvalid argument:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
有什么建议吗?
【问题讨论】:
标签: windows powershell syntax key jq