Skip to content
Open
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
11 changes: 8 additions & 3 deletions jqjq.jq
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,12 @@ def eval_ast($query; $path; $env; undefined_func):
else $input | length
end
) as $ve
| [ [null]
| [ ( $query_path
+ [ { start: if $start then $vs else null end
, end: if $end_ then $ve else null end
}
]
)
, $input[$vs:$ve]
]
)
Expand Down Expand Up @@ -2613,7 +2618,7 @@ def builtin_undefined_func($globals; $builtins_env):
$builtins_env;
builtin_undefined_func($globals; $builtins_env)
) as [$path, $value]
| [ if $path == [null] then $path
| [ if $path[0] == null then $path
else $f.path + $path
end
, $value
Expand All @@ -2636,7 +2641,7 @@ def eval($expr; $globals; $builtins_env):
# TODO: does not work with jq yet because issue with bind patterns
# $ gojq -cn -L . 'include "jqjq"; {} | {a:1} | eval(".a") += 1'
# {"a":2}
| if $path | . == [] or . == [null] then $value
| if $path | . == [] or .[0] == null then $value
else _getpath($path)
end
);
Expand Down
10 changes: 10 additions & 0 deletions jqjq.test
Original file line number Diff line number Diff line change
Expand Up @@ -1163,6 +1163,16 @@ map([paths])
{}
[]

# handle slices in path
getpath(path(.[1:][1:]))
[1,2,3]
[3]

# check for invalid path correctly
[1,2,3] | .[2]
null
3

# ascii_upcase
ascii_upcase
"123`abcdefghijklmnopqstuvxyz{"
Expand Down
Loading