Allow variable refs as object keys {$key:value}

Users are often surprised by the requirement to parenthesize any
non-trivial object key expressions in object constructors.  E.g.,
{"a"+"b":1}.  This commit adds one more kind of key expression besides
literals and idents: variable references.

A common use case for this is jq programs as JSON templates to fill in
with variables computed from inputs or passed in on the command-line.
E.g., {some_key:$value}.  Now users can also use, e.g., {$key:$value}.

This and the restrictions on key and value expressions in object
constructors are now clarified a bit in the documentation.
This commit is contained in:
Nicolas Williams committed 2018-12-10 21:54:59 -06:00
1 parent bb87e6e30f
commit 8ea4a5584e
3 files changed
+607 -583

No files matched your search

+584 -577
View File
File diff suppressed because it is too large. Load diff