Skip to content

Commit 3348d47

Browse files
committed
Fallback to json.el on Emacs without native JSON support
Some Emacs might not have native JSON support, however we could still use json.el.
1 parent 261eb47 commit 3348d47

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Diff for: drepl.el

+8-4
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,19 @@ The message is formed by calling `format' with STRING and ARGS."
158158
;;; Communication protocol
159159

160160
(defalias 'drepl--json-decode
161-
(if (json-available-p)
161+
(if (fboundp 'json-available-p)
162162
(lambda (s)
163163
(json-parse-string s :object-type 'alist :null-object nil))
164-
(error "Not implemented")))
164+
(require 'json)
165+
(declare-function json-read-from-string "json" ())
166+
#'json-read-from-string))
165167

166168
(defalias 'drepl--json-encode
167-
(if (json-available-p)
169+
(if (fboundp 'json-serialize)
168170
(lambda (s) (json-serialize s :null-object nil))
169-
(error "Not implemented")))
171+
(require 'json)
172+
(declare-function json-encode "json" ())
173+
#'json-encode))
170174

171175
(cl-defgeneric drepl--send-request (repl data)
172176
"Send request data to REPL.

0 commit comments

Comments
 (0)