我想从json解析文件路径的值。同时通过jq对其进行解析,并发现未在顶层定义的问题。请在下面找到json详细信息和错误:
"environment":{
"stage":{
"testing":[
{
"tag":"1.0"
"filepath":"C:/test/conf"
"hostname":"test"
}]}}
**command Used in Execute shell:**
jq -r ".'environment.stage.testing[].filePath' env.json
**Error Faced**:
jq: error: environments/0 is not defined at <top-level>, line 1:
environment.stage.testing[].filePath
jq: 1 compile error
TIA
最佳答案
hjson -j
.filePath
,而HJSON仅包含一个名为“filepath”的键。 .environment.stage.testing []。filepath
将以上内容放在一起:
$ hjson -j < so-jenkins-shell.hjson |
jq -r '.environment.stage.testing[].filepath'
C:/test/conf
关于json - jenkins Shell中解析json文件时出现jq错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51097759/