Function: majutsu-workspace--decode-json-field

majutsu-workspace--decode-json-field is a natively compiled function defined in majutsu-workspace.el.

Signature

(majutsu-workspace--decode-json-field VALUE)

Documentation

Decode JSON string field VALUE, returning nil for invalid data.

Preserve presentation properties applied to the encoded token.

Source Code

;; Defined in /nix/store/jagqw3nms546pad0gxi5f3wsckk6pji7-emacs-packages-deps/share/emacs/site-lisp/majutsu-workspace.el
(defun majutsu-workspace--decode-json-field (value)
  "Decode JSON string field VALUE, returning nil for invalid data.
Preserve presentation properties applied to the encoded token."
  (when value
    (condition-case nil
        (let ((decoded (json-parse-string value))
              (properties (and (not (string-empty-p value))
                               (text-properties-at 0 value))))
          (when (stringp decoded)
            (when (and properties (not (string-empty-p decoded)))
              (add-text-properties 0 (length decoded) properties decoded))
            decoded))
      (error nil))))