unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#42545: 28.0.50; json-pretty-print cant't handle json having "t" as a key
@ 2020-07-26  6:13 Marcelo Muñoz
  2020-07-26 10:38 ` Basil L. Contovounesios
  0 siblings, 1 reply; 7+ messages in thread
From: Marcelo Muñoz @ 2020-07-26  6:13 UTC (permalink / raw)
  To: 42545

[-- Attachment #1: Type: text/plain, Size: 773 bytes --]

Try to apply json-pretty-print to follow json:

{"t": 1, "key":2}

fail with the message:  json-pretty-print: Bad JSON object key: t

Some research point me the problem is in the function json-encode-key,
its  implementation is:

(defun json-encode-key (object)
  "Return a JSON representation of OBJECT.
If the resulting JSON object isn't a valid JSON object key,
this signals `json-key-format'."
  (let ((encoded (json-encode object)))
    (unless (stringp (json-read-from-string encoded))
      (signal 'json-key-format (list object)))
    encoded))


The follow change seems to  solve the problem, but I haven't had time
understand it in depth:

(defun json-encode-key (object)
   "Return s string representation of a key"
   (json-encode-string (symbol-name object)))

[-- Attachment #2: Type: text/html, Size: 980 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-02-23 12:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-26  6:13 bug#42545: 28.0.50; json-pretty-print cant't handle json having "t" as a key Marcelo Muñoz
2020-07-26 10:38 ` Basil L. Contovounesios
2021-02-11 14:20   ` Basil L. Contovounesios
2021-02-21 13:01     ` Basil L. Contovounesios
2021-02-23  1:23       ` Dmitry Gutov
2021-02-23  1:41         ` Basil L. Contovounesios
2021-02-23 12:10           ` Dmitry Gutov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).