Given a bash array, how to convert it to a JSON array in order to output to a file with jq?
Additionnally: is there a way to keep the server_nohup array unchanged instead of re-writing the whole json file each time?
newArray=(100 200 300)jq -n --arg newArray $newArray '{ client_nohup: [ $newArray ], server_nohup: [ ]}'> $projectDir/.watch.json
Current output:
{"client_nohup": ["100"],"server_nohup": []}
Desired output:
{"client_nohup": [ 100, 200, 300],"server_nohup": []}