It starts with an empty JSON object, and each jq
step in the pipeline further augments the structure. In case you want to step-by-step build up a JSON string in a shell.
The --arg
binds a string variable from bash to the jq-variable x
.
The jq expression ($x | fromjson)
parses the string into whatever JSON would be appropriate. So the bash variable true
becomes the proper true
boolean in the JSON. If we only would use $x
(instead of ($x | fromjson)
), the bash variable true
would become the JSON string "true"
.