I found the JSON array syntax a little unintuitive: $ jb dependencies:[,]=Bash,Grep {"dependencies":["Bash","Grep"]} One possible alternative would be to accept JSON literal snippets, like this: $ jb dependencies='["Bash", "Grep"]' This should support all forms of nested JSON objects. You could have a rule that if an argument does NOT parse as a valid JSON value it is treated as a raw string, so this would work: $ jb…
$ jb dependencies:json='["Bash","Grep"]'
{"dependencies":["Bash","Grep"]}
$ jb foo=bar bar:json='"this is a well formed string"'
{"foo":"bar","bar":"this is a well formed string"}
And then you can indeed use command substitution to nest calls: $ jb foo:json=$(jb bar=baz)
{"foo":{"bar":"baz"}}
It works even better to use process substitution, this way the shell gives jb a
file path to a file to read, and so you don't need to quote the $() to avoid whitespace breaking things: $ jb foo:json@
Another option is to use jb-array to generate arrays. (jb-array is best for tuple-like arrays with varying types): $ jb dependencies:json@
And if you use it from bash as a function, you can put values into a bash array and reference it: $ source json.bash
$ dependencies=(Bash Grep)
$ json @dependencies:[]
{"dependencies":["Bash","Grep"]}