From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Husain Alshehhi Newsgroups: gmane.emacs.help Subject: Parse a field in JSON given a path to the field Date: Thu, 11 Nov 2021 18:42:51 +0000 Message-ID: <87r1bmpm8n.fsf@alshehhi.io> Reply-To: Husain Alshehhi Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14077"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Nov 11 20:01:11 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mlFJu-0003TS-AU for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 11 Nov 2021 20:01:10 +0100 Original-Received: from localhost ([::1]:32868 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mlFJt-0001un-6N for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 11 Nov 2021 14:01:09 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:36472) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mlF2a-0001Vr-7S for help-gnu-emacs@gnu.org; Thu, 11 Nov 2021 13:43:18 -0500 Original-Received: from mail-4323.proton.ch ([185.70.43.23]:40735) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mlF2W-0000qn-Em for help-gnu-emacs@gnu.org; Thu, 11 Nov 2021 13:43:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alshehhi.io; s=protonmail2; t=1636656180; bh=qeqVFemxDj75dpdti063imaMewA9WK8pYA2gFny/ynY=; h=Date:To:From:Reply-To:Subject:From; b=QxNpkCKJTkiKjGPbIi5cZF1+0LYsCCPxoLspWIS27azvQ6AgEr/U7PLgrDCbGgpB/ fHniI6NkmXryuBN3LaGOXf5qmGLIuINb/WA56zNedyeeJP86522kKo5Av/YTtKp1t5 3Zn0t1qZZhkbNOpWI11VebHjXlkuIHJU+v8x8inMHAucIrBmpUHzqbPvwq/4Ch8Bw0 HpQIiNWauvxvaQolYy9GS8bu8xeYoQhMIfjvzPggSABkNyim/dnV4XWVqXYDBfyZ6Y +FcVMq7seiOQiRCDuA8Moos+zBuKC4hJDRFEYK8X0Ix9A2ENDQtz4AIUU7tBUhvEKC uQgnHlMfjCoWQ== Received-SPF: pass client-ip=185.70.43.23; envelope-from=husain@alshehhi.io; helo=mail-4323.proton.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 11 Nov 2021 13:59:39 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:134494 Archived-At: Does emacs provide a function that can return a path from a JSON object? I = find something like this useful if I want a field from a nested, large JSON= . Here is an example of a JSON string ,---- | { | "field" : { | "field1" : { | "field2" : { | "field3" : "value" | } | } | } `---- I do something like: ,---- | ;; assume that the value is in json-string | (let ((json (json-parse json-string)) | (field (gethash "field" json)) | (field1 (gethash "field1" field)) | (field2 (gethash "field2" field1)) | (field3 (gethash "field3" field2))) | ;; process field3 | ) `---- I wonder if there is something like ,---- | (let ((field3 (json-parse-path "field/field1/field2/field3" json-string))= ) | ;; process field3 | ) `----