From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Marcelo =?UTF-8?Q?Mu=C3=B1oz?= 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 02:13:09 -0400 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000097656505ab521a81" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23531"; mail-complaints-to="usenet@ciao.gmane.io" To: 42545@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 26 10:16:15 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 1jzbpP-00062c-GG for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 26 Jul 2020 10:16:15 +0200 Original-Received: from localhost ([::1]:38414 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jzbpO-0002J7-HU for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 26 Jul 2020 04:16:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37412) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jzbpC-0002Io-HB for bug-gnu-emacs@gnu.org; Sun, 26 Jul 2020 04:16:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40124) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jzbpC-0002b3-8H for bug-gnu-emacs@gnu.org; Sun, 26 Jul 2020 04:16:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jzbpC-00031L-4p for bug-gnu-emacs@gnu.org; Sun, 26 Jul 2020 04:16:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Marcelo =?UTF-8?Q?Mu=C3=B1oz?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 26 Jul 2020 08:16:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 42545 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.159575130711533 (code B ref -1); Sun, 26 Jul 2020 08:16:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 26 Jul 2020 08:15:07 +0000 Original-Received: from localhost ([127.0.0.1]:51668 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jzboH-0002zs-4y for submit@debbugs.gnu.org; Sun, 26 Jul 2020 04:15:07 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:56604) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jzZuc-0000Ad-98 for submit@debbugs.gnu.org; Sun, 26 Jul 2020 02:13:33 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48520) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jzZuc-00063E-1P for bug-gnu-emacs@gnu.org; Sun, 26 Jul 2020 02:13:30 -0400 Original-Received: from mail-io1-xd36.google.com ([2607:f8b0:4864:20::d36]:43500) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jzZua-0007KQ-FV for bug-gnu-emacs@gnu.org; Sun, 26 Jul 2020 02:13:29 -0400 Original-Received: by mail-io1-xd36.google.com with SMTP id k23so13763907iom.10 for ; Sat, 25 Jul 2020 23:13:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=qTIL3ASq+rlTtqjbtPifnajYOc1gsNvoX0v54/+GgME=; b=chmjIpNIoPVwWH5QFTHPQbwfrnwkzzrxueCRusy5m7K9RbpOih2IytMzcIog0rZP9I nE1QATw1K6uzOHsw8JKmvDyyRYh4JQOGLFxoZZrlzVFPl2Zz4pvcqY1K1AnY381tjjTO XoY0uuJ53z8c1C6cBnG+SgkSr0g1VzZU/6rMwAcnRHhsQoffCKBiek6tV07wbWR1wBhT eozbr09oLnS+bs5dFjKqB3l5nCVVxnv1TiYIC5EwgnnPhnPO7ZGIDgUQD0+0BKf+rhUY H4n5EKWL5mbzcj4P16ROnCADleNAmrt2KiQecWOoum3JJ/wLnf8WYr0u1SDGiE31F8w/ x6hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=qTIL3ASq+rlTtqjbtPifnajYOc1gsNvoX0v54/+GgME=; b=FY7bQ8w+HiYj3USY46INj/LE9qjL7o9Ul1kYltRu95wYf8/LRAZatfb+wESo2knyKo Er0IG/WuM00KxFKivTxaA7/yHgZyLrZJnoId0QJCgPALdl9tKQcrxBaeB2h1Gy371o1b TOJF+4W9UKQ72tMF6O8+gfm+kjLwh9nM/ZVvhgxOmXaBml6eWP8KDR+bF1oXgiIf4aBz GQze8p377jppdBFY36kK9tD8ScDnix+hi5fCS0AD86248cu9B8zV3Ap1gD11vUETJoh+ ehnQ3zRZPtAthhEvXE9IDZPslW1rk22l9qjwAdGpet9QCRWXDZ/HoTe95Aee4xR8mumW dLDQ== X-Gm-Message-State: AOAM531ilJlVGZg1nUA1Cq9wTkDpqkLeE4WZzR0bDdDYp3MIGeUkn3NE SzACuKsugDapLKr2X0gkX1Wouft0LD6d8HIberMK4KjkMT8= X-Google-Smtp-Source: ABdhPJzXQvRQlty9K+3gcRL1HtEgLXGCStbaieTja+guNOrvDNxo+RaHFXRVzBgS46mrCuiju3LcVYTWI2IzPZMpx74= X-Received: by 2002:a05:6602:2e95:: with SMTP id m21mr18299240iow.165.1595744005347; Sat, 25 Jul 2020 23:13:25 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::d36; envelope-from=ma.munoz.araya@gmail.com; helo=mail-io1-xd36.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 26 Jul 2020 04:15:04 -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:183565 Archived-At: --00000000000097656505ab521a81 Content-Type: text/plain; charset="UTF-8" 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 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))) --00000000000097656505ab521a81 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Try to apply json-pretty-print to follow json:

{&qu= ot;t": 1, "key":2}

fail with the message:=C2=A0 json-= pretty-print: Bad JSON object key: t

Some research point me the prob= lem is in the function json-encode-key,
its =C2=A0implementation is:
=
(defun json-encode-key (object)
=C2=A0 "Return a JSON represent= ation of OBJECT.
If the resulting JSON object isn't a valid JSON obj= ect key,
this signals `json-key-format'."
=C2=A0 (let ((enco= ded (json-encode object)))
=C2=A0 =C2=A0 (unless (stringp (json-read-fro= m-string encoded))
=C2=A0 =C2=A0 =C2=A0 (signal 'json-key-format (li= st object)))
=C2=A0 =C2=A0 encoded))


The follow change seems = to =C2=A0solve the problem, but I haven't had time
understand it in = depth:

(defun json-encode-key (object)
=C2=A0 =C2=A0"Return = s string representation of a key"
=C2=A0 =C2=A0(json-encode-st= ring (symbol-name object)))


--00000000000097656505ab521a81--