From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Bruce V Chiarelli Newsgroups: gmane.emacs.devel Subject: Re: two json.el bugs Date: Sun, 28 May 2017 15:44:04 -0700 Message-ID: <871sr87gaz.fsf@topd0g> References: <16aabb87-3130-41b8-968e-52bc5aea3956@default> <4054d683-e291-4512-b5c6-1b10997c0d02@default> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1496011487 29491 195.159.176.226 (28 May 2017 22:44:47 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 28 May 2017 22:44:47 +0000 (UTC) User-Agent: mu4e 0.9.19; emacs 26.0.50 Cc: Philipp Stephani , Theresa O'Connor , emacs-devel@gnu.org To: Drew Adams Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon May 29 00:44:39 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dF6vO-0007Uc-Gu for ged-emacs-devel@m.gmane.org; Mon, 29 May 2017 00:44:38 +0200 Original-Received: from localhost ([::1]:45549 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dF6vT-0005FJ-Tk for ged-emacs-devel@m.gmane.org; Sun, 28 May 2017 18:44:43 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dF6uw-0005FE-84 for emacs-devel@gnu.org; Sun, 28 May 2017 18:44:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dF6ut-0004ib-5u for emacs-devel@gnu.org; Sun, 28 May 2017 18:44:10 -0400 Original-Received: from mail-pg0-x22a.google.com ([2607:f8b0:400e:c05::22a]:33846) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dF6us-0004iU-Uo for emacs-devel@gnu.org; Sun, 28 May 2017 18:44:07 -0400 Original-Received: by mail-pg0-x22a.google.com with SMTP id u28so14606594pgn.1 for ; Sun, 28 May 2017 15:44:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version:content-transfer-encoding; bh=KQrxCFRAFiBrobTmXkJDr9OhG56yQ3SHmVnBY0Wt0r0=; b=rKjUGLm3QlK51Ej4boCmbgDMvxtvxeofzvfmjvswxym0psyf3BO0C3neKQU53XvKKP 3E5Px5cVXXmBCvmOGOt6BUS9gjD1siv9bfPXbbBgb+EffEflEJi3Op8SC3OEuc9LNGJr fGjjQvbrT/c0bNenKE04O01ZeWViUiyEdrW6AjEHkwW0UeV5ekI++8yUhA977JA+3BbL dJBB1v2ZRMswhdZtkjLUXP1u2sMaJnu1vM5ZaWd/sNOPMXsEuWpLGy83OddZTLEywm1B QyqGjo3Lihf+LMMwysLOywGaJrcen9cxd4SO07g3/Zpq6K5XPNbZ3pfVpZeJNIlBT7xL +2oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version:content-transfer-encoding; bh=KQrxCFRAFiBrobTmXkJDr9OhG56yQ3SHmVnBY0Wt0r0=; b=cVh+NtrVrue945jzdBxGQRzx7WOvxy46DkQKJ+LAjORQiu9tD/db+nZZO87vMVBSJo DtLFhVa/vq7EKSzLrmi0WeWd2vJ/YyyID7oB+unT4ZL5sI20vaevokihId+OkbIyXc2t e9W0qUF8ZT3b9yE1BBMVPqkktU+nQXSeO4E+TJSf2CRAu2WNIAI+FVilYko35KnelAlT 1xkarDqDx5pbStd0vy0kA5RuOpYqc52sGUp91uuowb0inw79l89+qEkgC6Op8QVAXpvN cA+RVXvsuuw2J6pZ/IQyM3GXl4gHcX3V5QQqFOs7CFz1V1jwj5+bcfC71H5AHzBU3S92 lIdA== X-Gm-Message-State: AODbwcDEdCr6p3BCzslcxT4uyT0YD3Jk0t50JP9H9qPdao2ZnLcjEveV TQXaRyoLbxSToqjPwK0= X-Received: by 10.98.137.93 with SMTP id v90mr14346846pfd.69.1496011445512; Sun, 28 May 2017 15:44:05 -0700 (PDT) Original-Received: from topd0g (c-73-118-158-137.hsd1.wa.comcast.net. [73.118.158.137]) by smtp.gmail.com with ESMTPSA id o8sm12454278pgn.52.2017.05.28.15.44.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 28 May 2017 15:44:04 -0700 (PDT) In-reply-to: <4054d683-e291-4512-b5c6-1b10997c0d02@default> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::22a X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:215295 Archived-At: Drew Adams writes: >> > > We can't simply serialize/desterialize alists in key order >> > > because the order is reversed in Emacs. (In Emacs alists, >> > > if there are duplicates, the first one wins, >> > > in JSON the last one wins.) >> >   ^^^^^^^^^^^^^^^^^^^^^^^^^ >> > >> > If you're talking about JSON objects then no, no particular >> > meaning or behavior is defined for duplicate fields (keys) >> > in a JSON object. >> > >> > A given application that handles JSON object is free to >> > act as you say.  And it is free to act otherwise. >> >> Please see Theresa's initial post why this matters. > > It is generally good to preserve the order. With > that general intention I agree. > > What's not true is that "in JSON the last one wins" > when there are duplicates. JSON itself imposes no > such semantics. > > And I question mention of "the standard JS > implementation". No such thing, AFAIK. ECMA 404 doesn't specify anything about duplicate keys, but the JSON parser behavior required by Section 24.3 of ECMA 262 does indeed. It's not an implementation of course, but it does dictate how compliant JS implementations should handle JSON. >From the end of listing 24.3.1.1: "In the case where there are duplicate name Strings within an object, lexically preceeding values for the same key shall be overwritten" (https://www.ecma-international.org/ecma-262/7.0/index.html#sec-internalizejsonproperty). It could be argued that Emacs does not need to have (or pretend to have) a 262-conforming parser. After all, it's not a JS interpreter. But as Tess mentioned, this particular point creates interoperability issues with conforming interpreters. --- Bruce V. Chiarelli