Can I pass a string variable to jq not the file?

前端 未结 7 1304
春和景丽
春和景丽 2020-12-29 03:58

I want to convert JSON string into an array in bash. The JSON string is passed to the bash script as an argument (it doesn\'t exist in a file).

Is there a way of ach

7条回答
  •  萌比男神i
    2020-12-29 04:22

    If you're trying to do this in a .sh file, this is what worked for me:

    local json_data $(getJiraIssue "$1")               # store JSON in var
    echo `jq -n "$json_data" | jq '.fields.summary'`   # pass that JSON var to jq
    

提交回复
热议问题