[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: small seq function for json data
From: |
Nicolas Petton |
Subject: |
Re: small seq function for json data |
Date: |
Mon, 17 Oct 2016 10:34:58 +0200 |
Stefan Huchler <address@hidden> writes:
> Hello,
Hi Stefan,
> So inspired by let-alist I wrote a more powerful version that supports
> also vector which is also used in json messages.
>
> (setq x '((foo . [((bar . "string of interest"))])))
>
> (defun sbit-seq-get (seq path)
> (cond ((null path) seq)
> ((listp seq)
> (sbit-seq-get (cdr (assoc (car path) seq)) (cdr path))
> )
> ((vectorp seq)
> (sbit-seq-get (elt seq (car path)) (cdr path))
> )
> (t seq)))
>
> (sbit-seq-get x '(foo 0 bar))
Did you have a look at `map-nested-elt'? I often use it to access JSON
data.
Cheers,
Nico
signature.asc
Description: PGP signature