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: small seq function for json data Date: Mon, 17 Oct 2016 10:34:58 +0200 Message-ID: <87twcbbcgd.fsf@petton.fr> References: <871szglv3y.fsf@jupiter.lan> 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 1476693386 27432 195.159.176.226 (17 Oct 2016 08:36:26 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 17 Oct 2016 08:36:26 +0000 (UTC) To: Stefan Huchler , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 17 10:36:21 2016 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 1bw3P8-0006HP-AH for ged-emacs-devel@m.gmane.org; Mon, 17 Oct 2016 10:36:18 +0200 Original-Received: from localhost ([::1]:59836 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bw3PA-0007Hr-Eo for ged-emacs-devel@m.gmane.org; Mon, 17 Oct 2016 04:36:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34348) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bw3Nx-0006Qr-Cz for emacs-devel@gnu.org; Mon, 17 Oct 2016 04:35:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bw3Nu-0005mf-67 for emacs-devel@gnu.org; Mon, 17 Oct 2016 04:35:05 -0400 Original-Received: from out1-smtp.messagingengine.com ([66.111.4.25]:52737) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bw3Nu-0005kj-39 for emacs-devel@gnu.org; Mon, 17 Oct 2016 04:35:02 -0400 Original-Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 82D302060D; Mon, 17 Oct 2016 04:35:00 -0400 (EDT) Original-Received: from frontend1 ([10.202.2.160]) by compute5.internal (MEProxy); Mon, 17 Oct 2016 04:35:00 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=smtpout; bh=p3pfnFZX5hCSEwOAZUP0h5nEYFQ=; b=nVHFX F3kKlIvUu2rtxFxDmNs/ouOdl9njMN9WO5QNFjHYDNRA82RvFk2+Z/EacQQFvXNb dFXzswlcmygtbuZd322AJZDZM24a9K6UpvxQ6kVJOrNQ7zpY8tBGycI8vUYXlwo2 4TTg6+9KvQleX4VjsFbGsSb7mBZKOP4hZUqthU= X-Sasl-enc: qhMJkoesWG8wSEYLpiLy32HCq4GANLOR/pWFcG4mfDce 1476693300 Original-Received: from blueberry (60.102.92.92.rev.sfr.net [92.92.102.60]) by mail.messagingengine.com (Postfix) with ESMTPA id E2A4CF29CF; Mon, 17 Oct 2016 04:34:59 -0400 (EDT) In-Reply-To: <871szglv3y.fsf@jupiter.lan> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.25 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:208348 Archived-At: --=-=-= Content-Type: text/plain Stefan Huchler 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 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: GPGTools - http://gpgtools.org iQEcBAEBCAAGBQJYBI0yAAoJECM1h6R8IHkQY8wH/jnzbGQT4L8/jWhzPXm8fgev fZqvjKlGE/QNW0sdWWVoTmw8fXSJ/0xepOtk3SGqLAs2XzXzFPhCAC/43ZcE0AFv QdWEz9kFIATTnN1xrydjX0PndadtdYAPP3blYMOAyFpVEEuMOrwtewHIoKnpHPKP SuhAfV0nbRaKQQR6jf8PJoC+04MtfPuNFVm5UZWiVKP4+RfWy2uFVy2AkTtUXNEa tOYpRDOzuz1bj5+TGB0+OSucWWyf0fMAam4hZY29gFtF9+gojNDO6mRdhMQuUtPp gDTvBfF7Gw4cipwuzBfnpdZMF5ZQe4fTc8P5QwJ19yneHzP45xAk/O9CGtISeDw= =i1Tq -----END PGP SIGNATURE----- --=-=-=--