Function: sops--parse-filestatus

sops--parse-filestatus is a natively compiled function defined in sops.el.

Signature

(sops--parse-filestatus JSON-STRING)

Documentation

Parse JSON-STRING from sops filestatus.

Return t if and only if the parsed object contains the boolean true at key encrypted. Any other shape -- nil input, non-string input, parse error, missing key, non-boolean value -- collapses to nil so callers can treat a nil return as not known to be encrypted rather than definitely plaintext. Leading/trailing whitespace in JSON-STRING is trimmed.

Source Code

;; Defined in /nix/store/vihl6lkzddv9xrsrsznvqdjq27g2i30p-emacs-packages-deps/share/emacs/site-lisp/elpa/sops-20260920.2121/sops.el
(defun sops--parse-filestatus (json-string)
  "Parse JSON-STRING from `sops filestatus'.
Return t if and only if the parsed object contains the boolean true at
key `encrypted'.  Any other shape -- nil input, non-string input, parse
error, missing key, non-boolean value -- collapses to nil so callers can
treat a nil return as `not known to be encrypted' rather than `definitely
plaintext'.  Leading/trailing whitespace in JSON-STRING is trimmed."
  (condition-case nil
      (let* ((trimmed (string-trim json-string))
             (parsed (json-parse-string trimmed :object-type 'alist)))
        (eq t (cdr (assq 'encrypted parsed))))
    (error nil)))