Json jq-根据字段的条件值添加自定义消息

Json jq-根据字段的条件值添加自定义消息,json,conditional-statements,jq,Json,Conditional Statements,Jq,是否可以根据字段值中的条件添加自定义消息?在我的例子中,我有以下json: { "plan_execution_metrics": { "total": 2, "passed": 1, "failed": 1 }, "journey_execution_metrics": { "total": 151, "passed": 140, "failed": 11 } }

是否可以根据字段值中的条件添加自定义消息?在我的例子中,我有以下json:

{
    "plan_execution_metrics": {
        "total": 2,
        "passed": 1,
        "failed": 1
    },
    "journey_execution_metrics": {
        "total": 151,
        "passed": 140,
        "failed": 11
    }
}
我希望得到一个结果jq,如果.tourney\u execution\u metrics.tourney\u execution\u metrics.failed==0,则输出“status”==SUCCESS,否则输出“status”==failed。以下是我目前掌握的情况:

 curl -s http://www.mocky.io/v2/5d8bc42f350000ad02d47227 | jq -r '. | {type:"google-tests", plan_execution_metrics: .plan_execution_metrics, journey_execution_metrics: .journey_execution_metrics, success:(.journey_execution_metrics.failed ==0) }'
但这会返回一个布尔值,即我的条件值,表示成功,而不是失败

{
  "type": "google-tests",
  "plan_execution_metrics": {
    "total": 2,
    "passed": 1,
    "failed": 1
  },
  "journey_execution_metrics": {
    "total": 151,
    "passed": 140,
    "failed": 11
  },
  "success": false
}


以下是一个为可读性而格式化的解决方案:

.status |= 
  if .journey_execution_metrics.failed == 0
  then "SUCCESS"
  else "FAILED"
  end