unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#34242: 26.1; json-encode crudely rejects unwelcome objects
@ 2019-01-29 14:01 phs
  2019-07-09 17:42 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: phs @ 2019-01-29 14:01 UTC (permalink / raw)
  To: 34242

json-encode is supposed to return a JSON representation of its argument.

It fails on some objects:

  (setq debug-on-error t)
  (require 'json)

  (json-encode (list (list 1)))

  ==> Debugger entered--Lisp error: (json-key-format 1)

  (json-encode (list (cons (cons 'a 'b) 'a)))

  ==> Debugger entered--Lisp error: (wrong-type-argument listp a)

I understand that maybe not all objects make sense for json-encoding but
the documentation of json-encode does not specify what is a valid
argument, and (it seems) the package does not do it either.

Also the documentation does not list the error-codes so that we could
catch them in code.

--phs





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

* bug#34242: 26.1; json-encode crudely rejects unwelcome objects
  2019-01-29 14:01 bug#34242: 26.1; json-encode crudely rejects unwelcome objects phs
@ 2019-07-09 17:42 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2019-07-09 17:42 UTC (permalink / raw)
  To: phs; +Cc: 34242

phs <phs@lsv.fr> writes:

> json-encode is supposed to return a JSON representation of its argument.
>
> It fails on some objects:
>
>   (setq debug-on-error t)
>   (require 'json)
>
>   (json-encode (list (list 1)))
>
>   ==> Debugger entered--Lisp error: (json-key-format 1)
>
>   (json-encode (list (cons (cons 'a 'b) 'a)))
>
>   ==> Debugger entered--Lisp error: (wrong-type-argument listp a)
>
> I understand that maybe not all objects make sense for json-encoding but
> the documentation of json-encode does not specify what is a valid
> argument, and (it seems) the package does not do it either.
>
> Also the documentation does not list the error-codes so that we could
> catch them in code.

I've now added some text to this function (and json-read) about what the
inputs, return values are and what error signals are raised to the Emacs
trunk.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

end of thread, other threads:[~2019-07-09 17:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-29 14:01 bug#34242: 26.1; json-encode crudely rejects unwelcome objects phs
2019-07-09 17:42 ` Lars Ingebrigtsen

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).