emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: JSON->lisp Mapping: Hash vs AList


From: Nicolas Petton
Subject: Re: JSON->lisp Mapping: Hash vs AList
Date: Tue, 12 Dec 2017 14:08:16 +0100

raman <address@hidden> 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

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]