Skip to main content
8 events
when toggle format what by license comment
Oct 6, 2024 at 5:11 comment added Stéphane Chazelas An object key can be any string, including "", "[]", "null", etc. jo -- -s "$n=$n" will help for n=--help or n=1, not for [], null, @x, a=b... jo's interface is severely broken by design IMO.
Oct 5, 2024 at 22:41 comment added Kusalananda Shorter with .[$n] = $n.
Oct 5, 2024 at 17:18 comment added jesse_b @StéphaneChazelas: Interesting that --help breaks it even when using --. 1 works for me and wouldn't [] as a key be invalid json anyway though?
Oct 5, 2024 at 16:35 comment added Stéphane Chazelas Or just jq -n --arg n foo '{($n): $n}'. Beware that jo syntax won't necessarily interpret all $n values as strings. Try with --help, 1 or [] for instance.
Oct 5, 2024 at 16:34 comment added Richard Barraclough Ta, adding brackets is what it needed. Never heard of jo -- looks like it could make thngs easier to construct an object then forward it via xargs to jq as a --jsonarg.
Oct 5, 2024 at 16:32 vote accept Richard Barraclough
Oct 5, 2024 at 12:34 history edited jesse_b CC BY-SA 4.0
added 311 characters in body
Oct 5, 2024 at 12:28 history answered jesse_b CC BY-SA 4.0