JQ错误Cannot index string with number with scan
JQ error Cannot index string with number with scan
我的扫描功能出错,为什么?
https://jqplay.org/s/E-0qbbzRPS
我需要在没有 -r 的情况下执行此操作
您的过滤器有两个问题。首先,您需要使用分号 ;
而非逗号 ,
:
将参数分隔为函数
scan("([0-9A-Za-z_]+) == '([0-9A-Za-z_]+)"; "g")
其次,带有两个参数的scan
没有实现(与manual相矛盾)。
jq: error: scan/2 is not defined at <top-level>, line 1:
但是当你使用 scan
时,你的正则表达式无论如何都会匹配多次出现,所以你最好放弃它 :
.spec.selector | [scan("([0-9A-Za-z_]+) == '([0-9A-Za-z_]+)") | {(.[0]): .[1]}]
[
{
"app": "nginx"
}
]
我的扫描功能出错,为什么?
https://jqplay.org/s/E-0qbbzRPS
我需要在没有 -r 的情况下执行此操作
您的过滤器有两个问题。首先,您需要使用分号 ;
而非逗号 ,
:
scan("([0-9A-Za-z_]+) == '([0-9A-Za-z_]+)"; "g")
其次,带有两个参数的scan
没有实现(与manual相矛盾)。
jq: error: scan/2 is not defined at <top-level>, line 1:
但是当你使用 scan
时,你的正则表达式无论如何都会匹配多次出现,所以你最好放弃它 :
.spec.selector | [scan("([0-9A-Za-z_]+) == '([0-9A-Za-z_]+)") | {(.[0]): .[1]}]
[
{
"app": "nginx"
}
]