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

查找以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 $ c扩展了规范$ C>;并使以下成为可能

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