查找以JSON Path开头的JSON属性名称

编程入门 行业动态 更新时间:2024-10-26 00:22:47
本文介绍了查找以JSON Path开头的JSON属性名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否可以使用JSON Path找到与正则表达式模式(或至少以其开头)匹配的属性名称。在XPath中我可以使用 name()但是我找不到等效的JSON路径。

Is it possible to find a property name that matches a regex pattern (or at least starts with) using JSON Path. In XPath I can use name() but I haven't been able to find the JSON Path equivalent.

基本上,我找到所有以 x开头的属性名称 - 。类似 $ .. x - * 。

Basically, I what to find all property names that start with x-. Something like $..x-*.

我有兴趣使用任何 javascript包这样做。目前,我正在使用 JSONPath 。

I'll be interested in using any javascript package that does this. Currently, I'm using JSONPath.

推荐答案

从我的谷歌搜索中,这在标准 json路径中是不可能的。但是, JSONPath 软件包使用 @path ;并使以下成为可能

From my googling this is not possible in standard json path. However, the JSONPath package extends the specification with @path; and makes the following possible

$..[?(@path.includes("[\'x-"))]

以上假设您使用的是 ES6 。

更多推荐

查找以JSON Path开头的JSON属性名称

本文发布于:2023-11-06 05:28:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1562823.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:开头   属性   名称   JSON   Path

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!