Function: json-ts--path-to-jq
json-ts--path-to-jq is a byte-compiled function defined in
json-ts-mode.el.gz.
Signature
(json-ts--path-to-jq PATH)
Documentation
Convert PATH list to a jq-style path string.
PATH is a list of keys (strings) and indices (numbers).
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/json-ts-mode.el.gz
(defun json-ts--path-to-jq (path)
"Convert PATH list to a jq-style path string.
PATH is a list of keys (strings) and indices (numbers)."
(mapconcat
(lambda (x)
(cond
((numberp x) (format "[%d]" x))
((stringp x)
(let ((key (string-trim x "\"" "\"")))
(if (string-match-p (rx bos (any alpha "_") (* (any alnum "_")) eos) key)
(format ".%s" key)
(format "[%S]" key))))
(t "")))
path
""))