From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Nicolas Petton Newsgroups: gmane.emacs.devel Subject: Re: JSON->lisp Mapping: Hash vs AList Date: Tue, 12 Dec 2017 14:08:16 +0100 Message-ID: <87wp1sw0u7.fsf@petton.fr> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Trace: blaine.gmane.org 1513084150 22888 195.159.176.226 (12 Dec 2017 13:09:10 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 12 Dec 2017 13:09:10 +0000 (UTC) To: raman , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Dec 12 14:09: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 1eOkIx-0005Vg-He for ged-emacs-devel@m.gmane.org; Tue, 12 Dec 2017 14:09:03 +0100 Original-Received: from localhost ([::1]:58263 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eOkJ1-0002A6-IB for ged-emacs-devel@m.gmane.org; Tue, 12 Dec 2017 08:09:07 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44159) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eOkIL-0001oW-An for emacs-devel@gnu.org; Tue, 12 Dec 2017 08:08:29 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eOkIH-0006WR-BK for emacs-devel@gnu.org; Tue, 12 Dec 2017 08:08:25 -0500 Original-Received: from petton.fr ([89.234.186.68]:48766) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eOkIH-0006Vk-0h for emacs-devel@gnu.org; Tue, 12 Dec 2017 08:08:21 -0500 In-Reply-To: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=petton.fr; s=mail; t=1513084097; bh=A2zx06HTQ2zBAeRUgLtuvrik0cvJsbigRyTJ8OUKotA=; h=From:To:Subject:In-Reply-To:References:Date:Message-ID:MIME-Version:Content-Type; b=GfL34VTldfix8/3NqqIjA59x5/npH0ldr2x0CplpXSIOCReth843Z74oU8R8GisSd0EYzde+Q3iMHJz9f2uNuBzEt5aBMiwhJVWV6Yqn9EI4JAJseaV31ukGIdt9ADP00qQlUCoyT7B/F77QKlOLGpF3Hfn0TyA4CezYDDUqE4U= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 89.234.186.68 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:220921 Archived-At: --=-=-= Content-Type: text/plain raman writes: > 2. The deeply nested nature of JSON dicts makes accessing things at > deeper levels require nested calls to gethash -- leads to code that > is opaque. I agree that an option for alists would be nice. However, you could use `map-nested-elt' to traverse any map (hash-table or alist): (map-nested-elt my-table '(key1 key2 key3)) map.el also provides `map-let' and a "map" `pcase' pattern, which can be used to traverse nested hash-tables (and also works on alists, or a mix): (pcase-let (((map ('key1 (map ('key2 (map key3))))) my-table)) ...) Cheers, Nico --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEKNO+2FH986tX/vk8IzWHpHwgeRAFAlov1MAACgkQIzWHpHwg eRBH0Af9Gn/rSzua2a1vHuhle1mEj3mgFA9nFxmFmIqx9SE8zOOpCDmhhON/6sW4 2MQyWLAqlYb6Fyi3EC0uO5t3qOiilFpZFuki3XNT40hQvywSx/twuwX11jTi45A/ JqSSyblNe32RILbVd/X84QaCuLXus2QsDh83XXlLY51vZ+fgZS8U8SNymkK8uif4 +dPnbIEw1rmoVY3cuebrqnH2NQyF+oPH07s6xpieHJvUcGNzB0+xFWs9Z+OE+3Sa DbAgA/VeM0+BAmPP42ZZk+9Hq02PQWoaKM6ilqtmmTRawhyRwN5WQ/PN5/TF9BY2 zajFK6WlAz9LupMXyWC2L7M5hPPUWg== =TLSt -----END PGP SIGNATURE----- --=-=-=--