From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#24252: 25.1; json.el doesn't distinguish null and empty object Date: Sat, 27 Aug 2016 03:05:41 +0300 Message-ID: <809ddc8d-8cd1-387b-fec6-fec60e0bd9c9@yandex.ru> References: <0e859022-309d-576d-62ea-acaddb10a0c2@yandex.ru> <4d97b2a8-5b96-6c22-7b00-95ef8bd5f6fd@yandex.ru> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1472256391 28344 195.159.176.226 (27 Aug 2016 00:06:31 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 27 Aug 2016 00:06:31 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:47.0) Gecko/20100101 Thunderbird/47.0 Cc: 24252@debbugs.gnu.org To: Yoichi Nakayama Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Aug 27 02:06:27 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1bdR8e-0006FW-06 for geb-bug-gnu-emacs@m.gmane.org; Sat, 27 Aug 2016 02:06:24 +0200 Original-Received: from localhost ([::1]:34223 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bdR8Z-0006JN-Lg for geb-bug-gnu-emacs@m.gmane.org; Fri, 26 Aug 2016 20:06:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49160) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bdR8Q-0006JG-PK for bug-gnu-emacs@gnu.org; Fri, 26 Aug 2016 20:06:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bdR8M-0004S3-8m for bug-gnu-emacs@gnu.org; Fri, 26 Aug 2016 20:06:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:44051) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bdR8M-0004Rz-46 for bug-gnu-emacs@gnu.org; Fri, 26 Aug 2016 20:06:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bdR8L-0001YC-Pm for bug-gnu-emacs@gnu.org; Fri, 26 Aug 2016 20:06:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 27 Aug 2016 00:06:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24252 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 24252-submit@debbugs.gnu.org id=B24252.14722563505943 (code B ref 24252); Sat, 27 Aug 2016 00:06:01 +0000 Original-Received: (at 24252) by debbugs.gnu.org; 27 Aug 2016 00:05:50 +0000 Original-Received: from localhost ([127.0.0.1]:41763 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bdR8A-0001Xn-8D for submit@debbugs.gnu.org; Fri, 26 Aug 2016 20:05:50 -0400 Original-Received: from mail-lf0-f48.google.com ([209.85.215.48]:35839) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bdR89-0001Xb-21 for 24252@debbugs.gnu.org; Fri, 26 Aug 2016 20:05:49 -0400 Original-Received: by mail-lf0-f48.google.com with SMTP id f93so66885786lfi.2 for <24252@debbugs.gnu.org>; Fri, 26 Aug 2016 17:05:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=eu1TqQdDaipbpJ3w6vc9MKRkV4Obwgzvaxj4tP4uXs0=; b=wS8OB9W6lWZPg5tx5Jr4wYxDqnjjZR8bTgm7zk2pHF8a0Rxvi5oQbaFK6RUtM42NwP jd/hcXaYOwfuJo4O4373BE8dqAuPcNhxWPCm9z8+CZVx8t5PbQUUX0epBje5ZhBKQHx8 ckc+6J2UGkc+Eo163bPhOgnqChto6tDt6FBXd3rhN2AD1RAdQ63xbqLnYK8SnEuxzrrv c+zwj4bzLYCkDj3g2QUU0UiZrjqemH7u88+j20rSZ3vC/pY3EFK5St7w84yEfs70l4VH cgoS/AuQKY4CTXMQoMM8AxDnwpWvJUGxjJcgRISKb2/HVnjKGMYy+HBzT2IS9v0FjqW4 mOTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:subject:to:references:cc:from:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=eu1TqQdDaipbpJ3w6vc9MKRkV4Obwgzvaxj4tP4uXs0=; b=EDRhpPoIBufCswOW8dovCRCI5cnfyMI9EV8RJOQWFZKykMqe5M3yLVoU2Ojno9M9M6 uJX8FqVS9+jgSm4Qel6eR6/Y2RHqSGCOrIsQsWTLXTsKr4g9U9VzQBtiHguvjAvlBwNZ WEOCulc2XhK5RdFubq+ytZu1l6zveG+FDY89skkJgFqJlyc/1j0UkVNZx1beRb0UERWB YynK+llb9Eovg9IEmnFUCv7q1yYRe/fVy1CQOpv6YM0LTF5Z25lCjWTzkJ0srtv7zm0Q frc6qgkNmLvvB6bWTQ6vbBj3RbaqxaF84V5DqyxnClCJna26nnczDEE3IKLd9Na3DiEr DUYg== X-Gm-Message-State: AE9vXwPjzOJQZX4QFdwg1fWbBDHWRBZyRwaLbIEtStUfMdQf1snsy0WP2TaCU5gfE1Twzg== X-Received: by 10.25.22.152 with SMTP id 24mr2414333lfw.180.1472256343060; Fri, 26 Aug 2016 17:05:43 -0700 (PDT) Original-Received: from [192.168.1.190] ([178.252.127.239]) by smtp.googlemail.com with ESMTPSA id i125sm4298469lfd.29.2016.08.26.17.05.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Aug 2016 17:05:42 -0700 (PDT) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:122706 Archived-At: Hi Yoichi, Thanks, but the changes to tests like below seem to indicate that the code breaks backward compatibility in certain respect. I'm not sure we'll want to merge it for that reason. I'd like to know what other developers think. On 08/21/2016 06:06 PM, Yoichi Nakayama wrote: > (ert-deftest test-json-plist-to-alist () > (should (equal (json--plist-to-alist '()) '())) > - (should (equal (json--plist-to-alist '(:a 1)) '((:a . 1)))) > + (should (equal (json--plist-to-alist '(:a 1)) '((a . 1)))) > + (let ((json-key-type 'keyword)) > + (should (equal (json--plist-to-alist '(:a 1)) '((:a . 1))))) > (should (equal (json--plist-to-alist '(:a 1 :b 2 :c 3)) > - '((:a . 1) (:b . 2) (:c . 3))))) > + '((a . 1) (b . 2) (c . 3))))) > > (ert-deftest test-json-advance () > (json-tests--with-temp-buffer "{ \"a\": 1 }" > @@ -177,9 +179,16 @@ Point is moved to beginning of the buffer." > "\"\\nasdфыв\\u001f\u007ffgh\\t\""))) > > (ert-deftest test-json-encode-key () > - (should (equal (json-encode-key "foo") "\"foo\"")) > - (should (equal (json-encode-key 'foo) "\"foo\"")) > - (should (equal (json-encode-key :foo) "\"foo\"")) > + (let ((json-key-type 'string)) > + (should (equal (json-encode-key "foo") "\"foo\"")) > + (should-error (json-encode-key t) :type 'json-key-format)) > + (let ((json-key-type 'symbol)) > + (should (equal (json-encode-key 'foo) "\"foo\"")) > + (should (equal (json-encode-key t) "\"t\"")) > + (should (equal (json-encode-key :t) "\":t\""))) > + (let ((json-key-type 'keyword)) > + (should (equal (json-encode-key :foo) "\"foo\"")) > + (should-error (json-encode-key t) :type 'json-key-format)) > (should-error (json-encode-key 5) :type 'json-key-format) > (should-error (json-encode-key ["foo"]) :type 'json-key-format) > (should-error (json-encode-key '("foo")) :type 'json-key-format)) > @@ -238,9 +247,9 @@ Point is moved to beginning of the buffer." > (let ((hash-table (make-hash-table)) > (json-encoding-object-sort-predicate 'string<) > (json-encoding-pretty-print nil)) > - (puthash :a 1 hash-table) > - (puthash :b 2 hash-table) > - (puthash :c 3 hash-table) > + (puthash "a" 1 hash-table) > + (puthash "b" 2 hash-table) > + (puthash "c" 3 hash-table) > (should (equal (json-encode hash-table) > "{\"a\":1,\"b\":2,\"c\":3}")))) > > @@ -261,7 +270,7 @@ Point is moved to beginning of the buffer." > (should (equal (json-encode plist) "{\"a\":1,\"b\":2,\"c\":3}")))) > > (ert-deftest test-json-encode-alist-with-sort-predicate () > - (let ((alist '((:c . 3) (:a . 1) (:b . 2))) > + (let ((alist '((c . 3) (a . 1) (b . 2))) > (json-encoding-object-sort-predicate 'string<) > (json-encoding-pretty-print nil)) > (should (equal (json-encode alist) "{\"a\":1,\"b\":2,\"c\":3}")))) > @@ -270,7 +279,7 @@ Point is moved to beginning of the buffer." > (let ((json-encoding-pretty-print nil)) > (should (equal (json-encode-list '(:a 1 :b 2)) > "{\"a\":1,\"b\":2}")) > - (should (equal (json-encode-list '((:a . 1) (:b . 2))) > + (should (equal (json-encode-list '((a . 1) (b . 2))) > "{\"a\":1,\"b\":2}")) > (should (equal (json-encode-list '(1 2 3 4)) "[1,2,3,4]"))))