Skip to content

Different precedence of + operator than jq #72

@wheene

Description

@wheene

Hi, first off thanks for creating jackson-jq, it is great.

I encountered this case where jackson-jq behaves differently than jq

>> jq --version
jq-1.6
>> echo '{"a": 1, "b": 2}' | jq -c '{"x": 10} + . as {"a": $a} | {"y": $a}'
{"x":10,"y":1}
>> echo '{"a": 1, "b": 2}' | java -jar /tmp/jackson-jq-cli-0.0.12.jar -c '{"x": 10} + . as {"a": $a} | {"y": $a}'
{"y":1}

I suspect the problem lies in difference operator precedence than jq has as when quoted like this, the output matches that of jq

>> echo '{"a": 1, "b": 2}' | java -jar /tmp/jackson-jq-cli-0.0.12.jar -c '{"x": 10} + (. as {"a": $a} | {"y": $a})'
{"x":10,"y":1}

The example seems contrived but I tried to use similar construct with real data when I encountered this problem and after some investigation this was the simplest example I could shrink it down to.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions