From: Stephen Dolan Date: Tue, 17 Dec 2013 22:28:26 +0000 (+0000) Subject: Allow negated object values without parens. Fixes #247 X-Git-Tag: jq-1.4~60 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=18e828f17cc3f87728d57e424814df45b5eec7f1;p=jq Allow negated object values without parens. Fixes #247 --- diff --git a/parser.y b/parser.y index 4c0b6a2..bc7bba9 100644 --- a/parser.y +++ b/parser.y @@ -458,7 +458,9 @@ ExpD: ExpD '|' ExpD { $$ = block_join($1, $3); } | - +'-' ExpD { + $$ = BLOCK($2, gen_call("_negate", gen_noop())); +} | Term { $$ = $1; } diff --git a/tests/all.test b/tests/all.test index 259cdf2..f50b7eb 100644 --- a/tests/all.test +++ b/tests/all.test @@ -36,6 +36,10 @@ null null [] +{x: -1} +null +{"x": -1} + # The input line starts with a 0xFEFF (byte order mark) codepoint # No, there is no reason to have a byte order mark in UTF8 text. # But apparently people do, so jq shouldn't break on it.