branch: externals/compat
commit 20afc898975b5136dca150391c41f20613a28e95
Author: Philip Kaludercic <phil...@posteo.net>
Commit: Philip Kaludercic <phil...@posteo.net>

    Add :cond checks to json-* functions in compat-27.1
---
 compat-27.1.el | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/compat-27.1.el b/compat-27.1.el
index f9e22af..ddc94b3 100644
--- a/compat-27.1.el
+++ b/compat-27.1.el
@@ -171,6 +171,10 @@ represent a JSON false value.  It defaults to `:false'.
 In you specify the same value for `:null-object' and `:false-object',
 a potentially ambiguous situation, the JSON output will not contain
 any JSON false values."
+  :cond (condition-case nil
+            (json-parse-string "[]")
+          (json-unavailable t)
+          (void-function t))
   (require 'json)
   (let ((json-false (or (plist-get args :false-object) :false))
         (json-null (or (plist-get args :null-object) :null)))
@@ -181,6 +185,10 @@ any JSON false values."
 This is the same as (insert (json-serialize OBJECT)), but potentially
 faster.  See the function `json-serialize' for allowed values of
 OBJECT."
+  :cond (condition-case nil
+            (json-parse-string "[]")
+          (json-unavailable t)
+          (void-function t))
   (insert (apply #'compat--json-serialize object args)))
 
 (compat-defun json-parse-string (string &rest args)
@@ -207,6 +215,10 @@ to represent a JSON null value.  It defaults to `:null'.
 
 The keyword argument `:false-object' specifies which object to use to
 represent a JSON false value.  It defaults to `:false'."
+  :cond (condition-case nil
+            (json-parse-string "[]")
+          (json-unavailable t)
+          (void-function t))
   (require 'json)
   (condition-case err
       (let ((json-object-type (or (plist-get args :object-type) 'hash-table))
@@ -246,6 +258,10 @@ to represent a JSON null value.  It defaults to `:null'.
 
 The keyword argument `:false-object' specifies which object to use to
 represent a JSON false value.  It defaults to `:false'."
+  :cond (condition-case nil
+            (json-parse-string "[]")
+          (json-unavailable t)
+          (void-function t))
   (require 'json)
   (condition-case err
       (let ((json-object-type (or (plist-get args :object-type) 'hash-table))

Reply via email to