Add json-available-p
* doc/lispref/text.texi (Parsing JSON): Document it. * lisp/subr.el (json-available-p): New function (bug#49660).
This commit is contained in:
parent
654ef06070
commit
e4f323a82a
3 changed files with 38 additions and 14 deletions
|
@ -5301,11 +5301,20 @@ represents @code{@{@}}, the empty JSON object; not @code{null},
|
|||
@code{false}, or an empty array, all of which are different JSON
|
||||
values.
|
||||
|
||||
@defun json-available-p
|
||||
This predicate returns non-@code{nil} is Emacs has been built with
|
||||
@acronym{JSON} support, and the library is available on the current
|
||||
system.
|
||||
@end defun
|
||||
|
||||
If some Lisp object can't be represented in JSON, the serialization
|
||||
functions will signal an error of type @code{wrong-type-argument}.
|
||||
The parsing functions can also signal the following errors:
|
||||
|
||||
@table @code
|
||||
@item json-unavailable
|
||||
Signaled when the parsing library isn't available.
|
||||
|
||||
@item json-end-of-file
|
||||
Signaled when encountering a premature end of the input text.
|
||||
|
||||
|
|
35
etc/NEWS
35
etc/NEWS
|
@ -2024,6 +2024,27 @@ used instead. Uses of 'json-encode-list' should be changed to call
|
|||
one of 'json-encode', 'json-encode-alist', 'json-encode-plist', or
|
||||
'json-encode-array' instead.
|
||||
|
||||
** json.c
|
||||
|
||||
+++
|
||||
*** New function 'json-available-p'.
|
||||
This predicate returns non-nil if Emacs is built with libjansson
|
||||
support, and it is available on the current system.
|
||||
|
||||
+++
|
||||
*** Native JSON functions now signal an error if libjansson is unavailable.
|
||||
This affects 'json-serialize', 'json-insert', 'json-parse-srtring',
|
||||
and 'json-parse-buffer'. This can happen if Emacs was compiled with
|
||||
libjansson, but the DLL cannot be found and/or loaded by Emacs at run
|
||||
time. Previously, Emacs would display a message and return nil in
|
||||
these cases.
|
||||
|
||||
*** The JSON functions 'json-serialize', 'json-insert',
|
||||
'json-parse-string', and 'json-parse-buffer' now implement some of the
|
||||
semantics of RFC 8259 instead of the earlier RFC 4627. In particular,
|
||||
these functions now accept top-level JSON values that are neither
|
||||
arrays nor objects.
|
||||
|
||||
** xml.el
|
||||
|
||||
*** XML serialization functions now reject invalid characters.
|
||||
|
@ -3473,12 +3494,6 @@ locales. They are also available as aliases 'ebcdic-cp-*' (e.g.,
|
|||
'cp278' for 'ibm278'). There are also new charsets 'ibm2xx' to
|
||||
support these coding-systems.
|
||||
|
||||
** The JSON functions 'json-serialize', 'json-insert',
|
||||
'json-parse-string', and 'json-parse-buffer' now implement some of the
|
||||
semantics of RFC 8259 instead of the earlier RFC 4627. In particular,
|
||||
these functions now accept top-level JSON values that are neither
|
||||
arrays nor objects.
|
||||
|
||||
---
|
||||
** 'while-no-input-ignore-events' accepts more special events.
|
||||
The special events 'dbus-event' and 'file-notify' are now ignored in
|
||||
|
@ -3538,14 +3553,6 @@ To turn this on, set the variable 'w32-use-native-image-API' to a
|
|||
non-nil value. Please report any bugs you find while using the native
|
||||
image API via 'M-x report-emacs-bug'.
|
||||
|
||||
---
|
||||
** Native JSON functions now signal an error if libjansson is unavailable.
|
||||
This affects 'json-serialize', 'json-insert', 'json-parse-srtring',
|
||||
and 'json-parse-buffer'. This can happen if Emacs was compiled with
|
||||
libjansson, but the DLL cannot be found and/or loaded by Emacs at run
|
||||
time. Previously, Emacs would display a message and return nil in
|
||||
these cases.
|
||||
|
||||
---
|
||||
** The user option 'make-pointer-invisible' is now honored on macOS.
|
||||
|
||||
|
|
|
@ -6311,4 +6311,12 @@ of fill.el (for example `fill-region')."
|
|||
This is intended for internal use only."
|
||||
(internal--fill-string-single-line (apply #'format string objects)))
|
||||
|
||||
(defun json-available-p ()
|
||||
"Return non-nil if Emacs is has libjansson support."
|
||||
(and (fboundp 'json-serialize)
|
||||
(condition-case nil
|
||||
(json-serialize t)
|
||||
(:success t)
|
||||
(json-unavailable nil))))
|
||||
|
||||
;;; subr.el ends here
|
||||
|
|
Loading…
Add table
Reference in a new issue