help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help with list of list object passed to json-encode


From: Kaushal Modi
Subject: Help with list of list object passed to json-encode
Date: Wed, 27 Apr 2022 22:28:58 -0400

Hello,

I was experimenting with passing different s-exp objects to
json-encode, and realized that this fails:

(json-encode '((foo . ((1 2) (3 4 5)))))


=====
Debugger entered--Lisp error: (json-key-format 1)
  signal(json-key-format (1))
  (or (json--print-stringlike object) (signal 'json-key-format (list object)))
  json--print-key(1)
  json--print-pair(1 (2))
  #f(compiled-function (pair) #<bytecode 0x5209ab54774c382>)((1 2))
  mapc(#f(compiled-function (pair) #<bytecode 0x5209ab54774c382>) ((1
2) (3 4 5)))
  #f(compiled-function #'map #<bytecode
-0x18b5c7332ae7fea>)(json--print-pair ((1 2) (3 4 5)))
  apply(#f(compiled-function #'map #<bytecode -0x18b5c7332ae7fea>)
json--print-pair ((1 2) (3 4 5)) nil)
  map-do(json--print-pair ((1 2) (3 4 5)))
  (let ((json--print-indentation-prefix (if json-encoding-pretty-print
json--print-indentation-prefix "")) (json--print-keyval-separator (if
json-encoding-pretty-print ": " ":")) (json--print-indentation-depth
(1+ json--print-indentation-depth))) (map-do #'json--print-pair map)
(delete-char (- (length json-encoding-separator))))
  (if (map-empty-p map) nil (let ((json--print-indentation-prefix (if
json-encoding-pretty-print json--print-indentation-prefix ""))
(json--print-keyval-separator (if json-encoding-pretty-print ": "
":")) (json--print-indentation-depth (1+
json--print-indentation-depth))) (map-do #'json--print-pair map)
(delete-char (- (length json-encoding-separator)))) (or
json-encoding-lisp-style-closings (json--print-indentation)))
  json--print-map(((1 2) (3 4 5)))
  json--print-alist(((1 2) (3 4 5)))
  (cond ((json-alist-p list) (json--print-alist list)) ((json-plist-p
list) (json--print-unordered-map list)) ((listp list)
(json--print-array list)) ((signal 'json-error (list list))))
  json--print-list(((1 2) (3 4 5)))
  (cond ((json--print-keyword object)) ((listp object)
(json--print-list object)) ((json--print-stringlike object)) ((numberp
object) (prin1 object)) ((arrayp object) (json--print-array object))
((hash-table-p object) (json--print-unordered-map object)) ((signal
'json-error (list object))))
  json--print(((1 2) (3 4 5)))
  json--print-pair(foo ((1 2) (3 4 5)))
=====

But this passes:

(json-encode '((foo . [(1 2) (3 4 5)])))

I'd like to understand why it's so.. Or is this a bug?

Thanks!


--
Kaushal Modi



reply via email to

[Prev in Thread] Current Thread [Next in Thread]