From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.bugs Subject: bug#42545: 28.0.50; json-pretty-print cant't handle json having "t" as a key Date: Sun, 26 Jul 2020 13:38:59 +0300 Message-ID: <87d04imugs.fsf@tcd.ie> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6689"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 42545@debbugs.gnu.org To: Marcelo =?UTF-8?Q?Mu=C3=B1oz?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 26 12:40:29 2020 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 1jze4z-0001eE-Cv for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 26 Jul 2020 12:40:29 +0200 Original-Received: from localhost ([::1]:45650 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jze4y-0002gY-7u for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 26 Jul 2020 06:40:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38818) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jze4Y-0002gD-Lj for bug-gnu-emacs@gnu.org; Sun, 26 Jul 2020 06:40:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40295) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jze4X-00026O-OI for bug-gnu-emacs@gnu.org; Sun, 26 Jul 2020 06:40:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jze4X-0006aI-Lg for bug-gnu-emacs@gnu.org; Sun, 26 Jul 2020 06:40:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 26 Jul 2020 10:40:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42545 X-GNU-PR-Package: emacs Original-Received: via spool by 42545-submit@debbugs.gnu.org id=B42545.159575995125242 (code B ref 42545); Sun, 26 Jul 2020 10:40:01 +0000 Original-Received: (at 42545) by debbugs.gnu.org; 26 Jul 2020 10:39:11 +0000 Original-Received: from localhost ([127.0.0.1]:51839 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jze3j-0006Z2-Av for submit@debbugs.gnu.org; Sun, 26 Jul 2020 06:39:11 -0400 Original-Received: from mail-wm1-f47.google.com ([209.85.128.47]:37914) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jze3g-0006Yj-N8 for 42545@debbugs.gnu.org; Sun, 26 Jul 2020 06:39:09 -0400 Original-Received: by mail-wm1-f47.google.com with SMTP id f18so11985537wml.3 for <42545@debbugs.gnu.org>; Sun, 26 Jul 2020 03:39:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=Jw4Ht0iGbrqAI0G9+Q8ImNeDLhZWSbO7Q82J9EBMubA=; b=V1dd8mu/pTvR/EnvSyNcSp3MVyfGQfwuyi751TLeUNkarZ0c6YGSHDSLpXwYtasxu+ sBJn78mskU/G552mXOYoTAISFKi14gqNLwfWcRl3gIOiYZ/n6rQ2QeC8U5XG7Kdovj7e bvQR2x8vygqRAqrgFymgcp2BA2InhjgXrRHSvNNHC3uYIVbz5h/lg2ZAKQkl84pGb9Ik DJimEHDPWQeDd7T9OGR/R30VTqknOAPh3Iwgj3U4wFpx2X33nvhYHAbvnu1NXpOvzXDB AACbv/9DkecfyBPM3tIrG5kMizqaClZBgYw8n9cRmkeBiwngqoUI5S8wFL/Tmy27WFfl f6EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=Jw4Ht0iGbrqAI0G9+Q8ImNeDLhZWSbO7Q82J9EBMubA=; b=gV3L1KcpMKckrZ2YMGHMRbQ3ismT1fr007x6TLwkeKJGjqpA9c/zbzb+/bJRjk2PTV jgKxU5TQLWo6tpPU3y97f7aTB7ZPZO/sU36ihw0yO95cKecMQCEu1OIS+zl/62qdZ/dY rh+IdCAOh+vomhChxakR/GBZJgaSH5UDGdzl/pAD+IfAxx3P0GFUYq9xpe3dxw9mQB6r DFD/Lve6C7HVVt7Zw+jsuIw4LEnZgy3IqP97H91swFino0Zoe2Qka7bld7OVt0FN/Fbx lau0cY8GCZ+CnKt/ZtU6s75NX5F+pXjQVwzHnu+NJQVaaA8VP72LuVhlrx1We7TIAOH0 w0OQ== X-Gm-Message-State: AOAM533IdGackUKynv99caKH6gEos4KL6iP0CtYosq+FxsctxjLWmhZS DIMSVbR6x7BbUturJzVUoeNPKg== X-Google-Smtp-Source: ABdhPJx5XPxMmwq+gb88urrLGSvPXUB9NfA+q/wGNRRaSGeX0mHzYWduTPxPQRbfO4MFFjVuhuC1Qg== X-Received: by 2002:a1c:2d91:: with SMTP id t139mr15814682wmt.3.1595759942801; Sun, 26 Jul 2020 03:39:02 -0700 (PDT) Original-Received: from localhost ([80.233.33.180]) by smtp.gmail.com with ESMTPSA id j5sm4833760wmb.12.2020.07.26.03.39.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jul 2020 03:39:02 -0700 (PDT) In-Reply-To: ("Marcelo =?UTF-8?Q?Mu=C3=B1oz?="'s message of "Sun, 26 Jul 2020 02:13:09 -0400") 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:183569 Archived-At: retitle 42545 json-encode-key can't handle boolean values found 42545 24.5 quit Marcelo Mu=C3=B1oz writes: > Try to apply json-pretty-print to follow json: > > {"t": 1, "key":2} > > fail with the message: json-pretty-print: Bad JSON object key: t Here are some simpler repros: (json-encode '((nil . 0))) (json-encode '((t . 0))) (json-encode-key nil) (json-encode-key t) All of these fail with json-key-format since at least as far back as Emacs 24.5. > Some research point me the problem is in the function json-encode-key, > its implementation is: > > (defun json-encode-key (object) > "Return a JSON representation of OBJECT. > If the resulting JSON object isn't a valid JSON object key, > this signals `json-key-format'." > (let ((encoded (json-encode object))) > (unless (stringp (json-read-from-string encoded)) > (signal 'json-key-format (list object))) > encoded)) > > The follow change seems to solve the problem, but I haven't had time > understand it in depth: > > (defun json-encode-key (object) > "Return s string representation of a key" > (json-encode-string (symbol-name object))) This can't be TRT, because OBJECT is not always a symbol. See also https://debbugs.gnu.org/24252#26 for some precedent in rewriting json-encode-key without relying on json-encode. I'm AFK until start of August, but I'll try to have a better look at this when I get the chance if no-one beats me to it. Thanks, --=20 Basil