From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: JSON->lisp Mapping: Hash vs AList Date: Thu, 14 Dec 2017 18:27:53 +0200 Message-ID: <838te5uvee.fsf@gnu.org> References: Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1513268888 16262 195.159.176.226 (14 Dec 2017 16:28:08 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 14 Dec 2017 16:28:08 +0000 (UTC) Cc: emacs-devel@gnu.org, raman@google.com To: Philipp Stephani Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Dec 14 17:28:03 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 1ePWMb-0003qb-8c for ged-emacs-devel@m.gmane.org; Thu, 14 Dec 2017 17:28:01 +0100 Original-Received: from localhost ([::1]:41824 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePWMi-0004Iw-BJ for ged-emacs-devel@m.gmane.org; Thu, 14 Dec 2017 11:28:08 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePWMb-0004Io-MZ for emacs-devel@gnu.org; Thu, 14 Dec 2017 11:28:02 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePWMX-0007Rt-OE for emacs-devel@gnu.org; Thu, 14 Dec 2017 11:28:01 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:33968) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePWMX-0007RX-KU; Thu, 14 Dec 2017 11:27:57 -0500 Original-Received: from [176.228.60.248] (port=3271 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ePWMW-0006tM-Uu; Thu, 14 Dec 2017 11:27:57 -0500 In-reply-to: (message from Philipp Stephani on Wed, 13 Dec 2017 22:37:46 +0000) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e 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:221061 Archived-At: > From: Philipp Stephani > Date: Wed, 13 Dec 2017 22:37:46 +0000 > Cc: emacs-devel@gnu.org > > Sounds reasonable, here is a patch. Thanks. > -@defun json-parse-string string > +@defun json-parse-string string &key (object-type 'hash-table) Hmm.. why is there an apostrophe before "hash-table"? What do you want to get in the output there? And btw, I don't see "&key" mentioned anywhere in the ELisp manual, so I wonder whether the reader will understand what it means. > + case json_object_alist: > + { > + result = Qnil; > + const char *key_str; > + json_t *value; > + json_object_foreach (json, key_str, value) > + { > + Lisp_Object key = Fintern (json_build_string (key_str), Qnil); > + result > + = Fcons (Fcons (key, json_to_lisp (value, object_type)), > + result); > + } > + result = Fnreverse (result); Is there a reason for calling nreverse here? > +The keyword argument OBJECT-TYPE specifies which Lisp type is used to ^^^^^^^^^^^ Shouldn't that be `:object-type' (including quotes)?