Skip to content

Commit

Permalink
#81 fix index corruption
Browse files Browse the repository at this point in the history
  • Loading branch information
spyzhov committed Nov 25, 2024
1 parent 6000d73 commit e20e7ab
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions jsonpath.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,11 +628,10 @@ func eval(node *Node, expression rpn, cmd string) (result *Node, err error) {
if err != nil {
return
}
cloned := clone(slice)
if len(cloned) > 1 { // array given
stack = append(stack, ArrayNode("", cloned))
} else if len(cloned) == 1 {
stack = append(stack, cloned[0])
if len(slice) > 1 { // array given
stack = append(stack, ArrayNode("", clone(slice)))
} else if len(slice) == 1 {
stack = append(stack, slice[0])
} else { // no data found
stack = append(stack, nil)
}
Expand Down

0 comments on commit e20e7ab

Please sign in to comment.