Function: json-encode

json-encode is a byte-compiled function defined in json.el.gz.

Signature

(json-encode OBJECT)

Documentation

Return a JSON representation of OBJECT as a string.

OBJECT should have a structure like one returned by json-read. If an error is detected during encoding, an error based on json-error is signaled.

Probably introduced at or before Emacs version 28.1.

Aliases

json-encode-hash-table (obsolete since 28.1) json-encode-number (obsolete since 28.1)

Source Code

;; Defined in /usr/src/emacs/lisp/json.el.gz
(defun json-encode (object)
  "Return a JSON representation of OBJECT as a string.

OBJECT should have a structure like one returned by `json-read'.
If an error is detected during encoding, an error based on
`json-error' is signaled."
  (json--with-output-to-string (json--print object)))