JSONPath-Plus / JSONPath

A fork of JSONPath from http://goessner.net/articles/JsonPath/
Other
958 stars 169 forks source link

Feature request: compare jsonpaths #172

Open gregorychen3 opened 2 years ago

gregorychen3 commented 2 years ago

Motivation

General purpose feature

Current behavior

N/A

Desired behavior

It could be nice to be able check if a jsonpath is "selected" by another jsonpath. In other words, checking if one jsonpath is the superset of another:

E.g.,

const jp1 = new JsonPath("$.foo.*")
const jp2 = new JsonPath("$.foo.[0]")
jp1.isSupersetOf(jp2) // true

An isEqual feature would be nice as well:

```javascript
const jp1 = new JsonPath("$.foo.0")
const jp2 = new JsonPath("$.foo.[0]")
jp1.isEqual(jp2) // true

Alternatives considered

There doesn't seem to be any other libraries supporting this feature in javascript or typescript.