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.devel Subject: Native vs Elisp JSON key serialisation Date: Tue, 28 Jul 2020 21:16:45 +0300 Message-ID: <87365bbj3m.fsf@tcd.ie> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39236"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Jul 28 20:21:36 2020 Return-path: Envelope-to: ged-emacs-devel@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 1k0UEJ-000A5A-BT for ged-emacs-devel@m.gmane-mx.org; Tue, 28 Jul 2020 20:21:35 +0200 Original-Received: from localhost ([::1]:42022 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k0UEI-0000IF-E2 for ged-emacs-devel@m.gmane-mx.org; Tue, 28 Jul 2020 14:21:34 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39978) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k0U9p-0007DR-Au for emacs-devel@gnu.org; Tue, 28 Jul 2020 14:16:57 -0400 Original-Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]:54357) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k0U9n-0002Hh-Fc for emacs-devel@gnu.org; Tue, 28 Jul 2020 14:16:57 -0400 Original-Received: by mail-wm1-x32f.google.com with SMTP id d190so420979wmd.4 for ; Tue, 28 Jul 2020 11:16:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:mime-version; bh=rD+brA3j7dpMSIxMEwfU3HY94JUlIUkyLw6dpb1+ECo=; b=jkrJIjKGUXxUWmcZ6KI5wS5S7wY0MmnM/XeGjK70fU/qzUEL9/bNTlA4WT5kOcgYWD sP8kbt/qWwnaLjnEsVfVS381I5SBMlT1qRo4UUea728xzaE6ekpqT2SRHzzGcpNGOPe1 6+1t4ijHkdfL3X6CHDpSfhftLQ5SfEUZaQnaW3uZgLN6AtpeevaYdulqrPzv6iZwkM7S IpP3x5+qQsEgLm+63cOhLodIo6kmqiCr/m99JMkEoUfLHQUTiyRYNRXr9gTr0wEbMoe5 A4k+6pArYt3DgNCmh8tMly1dtyHFf0jG9yQ2YeYxgoqY89/DWQtHhW6ig9GsmFRcxYg3 I6Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=rD+brA3j7dpMSIxMEwfU3HY94JUlIUkyLw6dpb1+ECo=; b=j3tF7fmlKNe9HzeZZmFLRSpJLl0lN6K7HmaJvS9Vo8tYaPCben7yGeGHofh4G93469 eVAUqIW4dEZaoSO+EkOqwb3xzlJgBwkgLEKiBCkBzHCti+7SIb4VHIQxIvxBDS1/3eLq JdX7XZra7QYqtSCaG8CWRJJ1/yrfZ9ge4bRmUKDgtgjeLczyWKPjjhHIggfiOCQDvDV3 4GUauy3D5MtQnC4ttfJp9qBERPi7CFkulpM7hC+jLP3WHdoESD5UItyyWayMxNcRwldU fFoZBZAgS1AYAxfRXBVUKDQe1x1oWulSw4qNZdbUTfO5t5tSD20IZ7X+itgypH2gYN6I 13oA== X-Gm-Message-State: AOAM530Q1P9Ly0n1cFWUne/cJEnJ9Pk/LBlQjXDxbm6tqRJgTRTD8JEz pDqm58w/obn8Z6Y8M4fqULVxEZlQfUzVww== X-Google-Smtp-Source: ABdhPJz/fa7rYQPvHtk3MXH3kOnSeYHsSAx4YePNcnhESsjDuAyZpHFm0/9oqqHnt79JDTwjOTbW3w== X-Received: by 2002:a1c:1f85:: with SMTP id f127mr5418650wmf.154.1595960211175; Tue, 28 Jul 2020 11:16:51 -0700 (PDT) Original-Received: from localhost ([80.233.39.204]) by smtp.gmail.com with ESMTPSA id s19sm21288399wrb.54.2020.07.28.11.16.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 11:16:50 -0700 (PDT) Received-SPF: none client-ip=2a00:1450:4864:20::32f; envelope-from=contovob@tcd.ie; helo=mail-wm1-x32f.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: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:253314 Archived-At: While looking at bug#42545, I noticed some inconsistencies in object key serialisation between json-encode and json-serialize. When serialising hash tables: - json-encode translates the keys 'foo, :foo, and "foo" to "foo" - json-serialize translates "foo" to "foo" (and rejects symbols as keys) I don't have a problem with this; it makes sense to me that json.c is stricter, and json.el is older so has more backward compatibility to maintain. In other words, the two implementations are sufficiently consistent IMO. When serialising alists: - json-encode translates 'foo, :foo, and "foo" to "foo" - json-serialize translates 'foo to "foo", and :foo to ":foo" (and rejects strings as keys) Here the two implementations are inconsistent. Should the older json-encode also translate :foo to ":foo", or should the newer and more prominently (in the Elisp manual) documented json-serialize translate :foo to "foo"? When serialising plists: - json-encode translates :foo to "foo" (and interprets 'foo and "foo" as starting an array rather than associative object) - json-serialize translates 'foo and :foo to "foo" (and rejects strings as keys) Here the two implementations are again inconsistent. Should json-encode also accept plists with non-keyword symbols as keys, or should json-serialize accept only keywords as keys? In both cases, I'm inclined to change json-encode to be more consistent with json-serialize as the more authoritative of the two. Either way, I think the two implementations should be as consistent and thus interchangeable as possible. WDYT? -- Basil