jq cheat sheet

Delete index

jq 'del(.myarray[] | select(. == "b"))'
jq "del(.folders[] | select(.path == \"file://$symbolic_path\"))" /werm/werm-docker-srv/theia/workspace.theia-workspace

Multiple condition

jq -r ".[] | select(.name == \"$name\" and .version == \"$package_version\")";

Iterate through each index

for e in `echo $mounts | jq -c ".[]"` ; do
  source=`echo $e | jq -r .Source`
  destination=`echo $e | jq -r .Destination`;
  echo $source;
  echo $destination;
done

https://how.wtf/how-to-iterate-through-json-arrays-in-bash-using-jq.html

Leave a Reply

Your email address will not be published.