GNU bug report logs - #42994
27.1; json-serialize unable to serialize JSON values

Previous Next

Package: emacs;

Reported by: Jimmy Yuen Ho Wong <wyuenho <at> gmail.com>

Date: Sun, 23 Aug 2020 12:26:02 UTC

Severity: normal

Merged with 46486

Found in versions 27.1, 28.0.50

Done: Philipp <p.stephani2 <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Jimmy Yuen Ho Wong <wyuenho <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 42994 <at> debbugs.gnu.org
Subject: bug#42994: 27.1; json-serialize unable to serialize JSON values
Date: Sun, 23 Aug 2020 15:05:22 +0100
The answer seems to be setting JSON_ENCODE_ANY and JSON_DECODE_ANY

https://jansson.readthedocs.io/en/latest/apiref.html#encoding
https://jansson.readthedocs.io/en/latest/apiref.html#decoding

On Sun, Aug 23, 2020 at 1:56 PM Jimmy Yuen Ho Wong <wyuenho <at> gmail.com> wrote:
>
> (json-serialize t) ;; *** Eval error ***  Wrong type argument: json-value-p, t
> (json-serialize "foo") ;; *** Eval error ***  Wrong type argument:
> json-value-p, "foo"
> (json-serialize 1) ;; *** Eval error ***  Wrong type argument: json-value-p, 1
>
> These are all valid JSONs.
>
> On Sun, Aug 23, 2020 at 1:53 PM Eli Zaretskii <eliz <at> gnu.org> wrote:
> >
> > > From: Jimmy Yuen Ho Wong <wyuenho <at> gmail.com>
> > > Date: Sun, 23 Aug 2020 13:24:58 +0100
> > >
> > >
> > > According to the [JSON spec](https://www.json.org/json-en.html),
> > > everything is a value and every value is a valid JSON, which means
> > > literal string, numbers, and true, false and null are also valid JSON
> > > values, but `json-serialize` is unable to serialize literals. This is
> > > wrong and behaviorialy different from the elisp-based `json-encode`.
> >
> > Thank you for your report.  To allow us to process this issue quickly
> > and efficiently, please provide a couple of examples where
> > json-serialize is unable to serialize literals.




This bug report was last modified 4 years and 135 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.