我想在bash中将JSON字符串转换为array.
有没有一种不用临时文件就能实现的方法?
Similarly to this:
script.sh
#! /bin/bash
json_data='{"key":"value"}'
jq '.key' $json_data
jq: error: Could not open file {key:value}: No such file or directory
我想在bash中将JSON字符串转换为array.
有没有一种不用临时文件就能实现的方法?
Similarly to this:
script.sh
#! /bin/bash
json_data='{"key":"value"}'
jq '.key' $json_data
jq: error: Could not open file {key:value}: No such file or directory
I would suggest using a bash here string. e.g.
jq '.key' <<< "$json_data"