Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 657

How to add array from object's keys in jq

$
0
0

I want to add bundleDependencies from the dependencies's keys by using jq.

json_string="$(cat <<'END'{"name": "hello","dependencies": {"progress": "^2.0.0","tar": "^6.2.1"  }}END)"

Here is the command for adding bundleDependencies but got error:

# jq ".bundleDependencies = (.dependencies | keys[])" <<< "$json_string")"bash: syntax error near unexpected token `)'

Here is the expected output:

{"name": "hello","dependencies": {"progress": "^2.0.0","tar": "^6.2.1"  },"bundleDependencies": ["progress", "tar"]}

What's wrong in my jq command and how to fix?


Viewing all articles
Browse latest Browse all 657

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>