Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes variable binding in object destructuring #78

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ private void recursive(final Scope scope, final JsonNode in, final Functional.Co
final int size = accumulate.size();
matcher.match(scope, value != null ? value : NullNode.getInstance(), out, accumulate, emit && index == matchers.size() - 1);
recursive(scope, in, out, accumulate, emit, index + 1);
accumulate.setSize(size);
if(emit) // value in accumulate needs to remain visible until it is emitted
accumulate.setSize(size);
}
}

Expand Down
28 changes: 28 additions & 0 deletions jackson-jq/src/test/resources/jq-test-extra-ok.json
Original file line number Diff line number Diff line change
Expand Up @@ -729,5 +729,33 @@
"q": "\"\\/\"",
"in": null,
"out": ["/"]
},
{
"q": ". as {\"a\":$a, \"b\":$b, \"c\":$c} | [$a,$b,$c]",
"in": {"a":1, "b": 2,"c": 3},
"out": [
[1,2,3]
]
},
{
"q": ". as {\"outer\":{\"x\": $x}, \"x\": $y} | [$x, $y]",
"in": {"outer":{"x": 1}, "x": 2},
"out": [
[1,2]
]
},
{
"q": ". as {\"outer\":{\"x\": $x}, \"x\": $x} | $x",
"in": {"outer":{"x": 1}, "x": 2},
"out": [
1
]
},
{
"q": ". as {\"x\": $x, \"outer\":{\"x\": $x}} | $x",
"in": {"outer":{"x": 1}, "x": 2},
"out": [
2
]
}
]