From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philipp Newsgroups: gmane.emacs.bugs Subject: bug#42733: 27.1; json-serialize doesn't not encode list like json-encode Date: Mon, 5 Jul 2021 19:45:19 +0200 Message-ID: References: <875yyj6y7e.fsf@gnus.org> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.100.0.2.22\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16968"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 42733@debbugs.gnu.org, Philipp Stephani , Jimmy Yuen Ho Wong To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jul 05 19:46:18 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m0Sfh-00048z-M8 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 05 Jul 2021 19:46:17 +0200 Original-Received: from localhost ([::1]:51560 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0Sfg-0008LA-5b for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 05 Jul 2021 13:46:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38022) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0SfS-0008Kw-54 for bug-gnu-emacs@gnu.org; Mon, 05 Jul 2021 13:46:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35092) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m0SfR-0003F5-S5 for bug-gnu-emacs@gnu.org; Mon, 05 Jul 2021 13:46:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m0SfR-0001he-JW for bug-gnu-emacs@gnu.org; Mon, 05 Jul 2021 13:46:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Philipp Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 05 Jul 2021 17:46:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42733 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 42733-submit@debbugs.gnu.org id=B42733.16255071286505 (code B ref 42733); Mon, 05 Jul 2021 17:46:01 +0000 Original-Received: (at 42733) by debbugs.gnu.org; 5 Jul 2021 17:45:28 +0000 Original-Received: from localhost ([127.0.0.1]:46638 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m0Seu-0001gr-Lj for submit@debbugs.gnu.org; Mon, 05 Jul 2021 13:45:28 -0400 Original-Received: from mail-wr1-f48.google.com ([209.85.221.48]:42645) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m0Ses-0001ge-HS for 42733@debbugs.gnu.org; Mon, 05 Jul 2021 13:45:27 -0400 Original-Received: by mail-wr1-f48.google.com with SMTP id t6so13056216wrm.9 for <42733@debbugs.gnu.org>; Mon, 05 Jul 2021 10:45:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=W8MBIPJUWEkt8OW93ob+8kATxcKP43EsNyWz+gIndEE=; b=Ti9i3/J87Fw+qV3gUdakQV73TP8k70zJ4n0L9iqFWicUZnZpDc2KvVCoLazzXjGzlP j1/ouVqVZsLXjVF4WTwo7qLkVEYgCKiizZcvHh6CvPpw9NJfhGxVnzNX08r7TplorjG0 n6nHKjV0mZQT+2xkVSKV30BSrTVs1+YWhQNbjistcJ52hpK3AX01jOEZMo73xeNEHYCW CpwIJjq5aI3/nWsnOmVHbxBFMMzWrCs1ZfQ6yXC0qNg3IY/nmPlKzicyN+Zwp9LOHXMB 4w6Ugxqsr0NUj1PuFHorkNhWNwW0TYAAJjcdoZtZC+Z76iaSfzo/4BLjHWKId2De7NyU AhQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=W8MBIPJUWEkt8OW93ob+8kATxcKP43EsNyWz+gIndEE=; b=D3vsWsSTDYnbm29kPaqZxAzvcotrJ45BKPNWmZuXr4WYwLymmAmMflkTp4xZz7yW93 MjhMUW+OMAqir3kdr17rg20NbZyW5Fw3gMxHAav2vchr8ZgB5VAXrGUul3DAeDxZnEjE AGqYrgXvF4HNYZ/tM6/pS1Gaoc/qlCSgqf3ce/CR/WCW/sv/JMTBneo+8+OQzogGMoKX r5EaJsQbt4DIFZBmr1uFbxLvvTJfNoEJXgYijz0/Cv47sdBurm7HkvB08gFXAZzUkJV7 rlenhku7qhkTulUBpxJeZM/3mBv9/H5ABXCEA0i3lyzucNDZVv+jkE7D0Jy/8vsAoubQ vwOQ== X-Gm-Message-State: AOAM531xv1W/5B2UeH5UlVpwNGvCiWVF7Di62T7tP4xknn5w4I8tX6jW BijPwbOpTOgZjdgAUOOYKVw= X-Google-Smtp-Source: ABdhPJwNgY/xXtDkP+MW0C84IWeGJ2vJh3dm3QYo8iHurrOnxDMLrWrAuZJf755AXbP6Yc8pp7GyTg== X-Received: by 2002:adf:ebc6:: with SMTP id v6mr16720915wrn.398.1625507120627; Mon, 05 Jul 2021 10:45:20 -0700 (PDT) Original-Received: from smtpclient.apple ([46.128.198.100]) by smtp.gmail.com with ESMTPSA id y8sm13741020wrr.76.2021.07.05.10.45.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Jul 2021 10:45:20 -0700 (PDT) In-Reply-To: <875yyj6y7e.fsf@gnus.org> X-Mailer: Apple Mail (2.3654.100.0.2.22) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:209482 Archived-At: > Am 12.06.2021 um 14:53 schrieb Lars Ingebrigtsen : >=20 > Jimmy Yuen Ho Wong writes: >=20 >> (json-encode '("foo" "bar")) >> =3D> "[\"foo\",\"bar\"]" >>=20 >> (json-serialize '("foo" "bar")) >>=20 >> Debugger entered--Lisp error: (wrong-type-argument symbolp "foo") >> json-serialize(("foo" "bar")) >>=20 >> 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. >=20 > 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. >=20 > 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.=