Pointers and references: Difference between revisions

→‎{{header|jq}}: special case
(→‎{{header|jq}}: disambiguation)
(→‎{{header|jq}}: special case)
Line 1,043:
# getjsonpointer() is like getpath() but for jsonpointer pointers
def getjsonpointer($pointer):
if $pointer == "" then . # special case
. as $in
else
# first decode ~1, then ~0
| ($pointer | split("/") | .[1:]
| map(gsub("~1"; "/") | gsub("~0"; "~"))) as $array
| disambiguatePath($array) as $apath
| if $apath then getpath($apath) else null end;
end;
 
# like getpath() but allow $p to be a jsonpointer or an array
2,442

edits