From: Philipp <p.stephani2@gmail.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 42733@debbugs.gnu.org, Philipp Stephani <phst@google.com>,
Jimmy Yuen Ho Wong <wyuenho@gmail.com>
Subject: bug#42733: 27.1; json-serialize doesn't not encode list like json-encode
Date: Mon, 5 Jul 2021 19:45:19 +0200 [thread overview]
Message-ID: <F19015E7-324F-403C-93DB-B1A0FA0434A6@gmail.com> (raw)
In-Reply-To: <875yyj6y7e.fsf@gnus.org>
> Am 12.06.2021 um 14:53 schrieb Lars Ingebrigtsen <larsi@gnus.org>:
>
> Jimmy Yuen Ho Wong <wyuenho@gmail.com> writes:
>
>> (json-encode '("foo" "bar"))
>> => "[\"foo\",\"bar\"]"
>>
>> (json-serialize '("foo" "bar"))
>>
>> Debugger entered--Lisp error: (wrong-type-argument symbolp "foo")
>> json-serialize(("foo" "bar"))
>>
>> The potential for people to naively substitute json-encode with
>> json-serialize and breaking their code is enormous. This is already
>> happening in lsp-mode. Please make json-serialize behave like
>> json-encode.
>
> json.c is a lot less "DWIM" than json.el -- which I think is generally a
> good idea when it comes to doing round-trips between Elisp and JSON,
> because you avoid a lot of corner cases.
>
> So I'd be inclined to just regard this as a feature, but I've added
> Philipp to the CCs -- perhaps he has some comments.
What Lars said. In general, DWIM can be a good choice for high-level user-facing commands, but not for lower-level library functions like this. Second-guessing the intention of the caller often generates surprising or subtly wrong results, which isn't what you want for interpreting a rather low-level protocol like JSON. json-serialize thus very intentionally behaves differently than the json.el functions.
next prev parent reply other threads:[~2021-07-05 17:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-06 22:17 bug#42733: 27.1; json-serialize doesn't not encode list like json-encode Jimmy Yuen Ho Wong
2020-08-06 22:29 ` bug#42733: 27.1; json-serialize does " Jimmy Yuen Ho Wong
2020-08-07 2:18 ` 황병희
2021-06-12 12:53 ` bug#42733: 27.1; json-serialize doesn't " Lars Ingebrigtsen
2021-07-05 17:45 ` Philipp [this message]
2021-07-05 19:48 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=F19015E7-324F-403C-93DB-B1A0FA0434A6@gmail.com \
--to=p.stephani2@gmail.com \
--cc=42733@debbugs.gnu.org \
--cc=larsi@gnus.org \
--cc=phst@google.com \
--cc=wyuenho@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).