From 1d2dc0b1dd589559f3bf4d7e20253d5df0dc2fa9 Mon Sep 17 00:00:00 2001 From: avkiryanov Date: Fri, 21 Mar 2025 16:06:13 +0300 Subject: [PATCH] fix filter expression with several nodes A filtering expression like $[?(@.node1.node2)] will not find node2 because the cycle step is 2. If we rewrite the expression for $[?(@.node1.node2.node2)], node2 will be found. --- jsonpath.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsonpath.lua b/jsonpath.lua index d46a55d..c932c07 100755 --- a/jsonpath.lua +++ b/jsonpath.lua @@ -288,7 +288,7 @@ local function eval_ast(ast, obj) if obj == nil then return nil, 'object is not set' end - for i = 2, #expr, 2 do -- [1] is "var" + for i = 2, #expr, 1 do -- [1] is "var" local member, err = eval_ast(expr[i], obj) if member == nil then return nil, err