[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#42994: 27.1; json-serialize unable to serialize JSON values
From: |
Jimmy Yuen Ho Wong |
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@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@gnu.org> wrote:
> >
> > > From: Jimmy Yuen Ho Wong <wyuenho@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.