Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RegEx to the path filtering #949

Open
yk-jemmic opened this issue Jul 21, 2023 · 6 comments
Open

Add RegEx to the path filtering #949

yk-jemmic opened this issue Jul 21, 2023 · 6 comments

Comments

@yk-jemmic
Copy link

yk-jemmic commented Jul 21, 2023

It would be very useful to apply a regular expression to filter paths

Here is an example:

Having the json bellow how to get all the "name"s of "Bank"s? :

{
  "baseItem1": {
    "subItem1Bank": {
      "name": "ABC"
    },
    "subItem2Bank": {
      "name": "ING"
    },
    "subItem3Bank": {
      "name": "JPMorgan"
    }
  },
  "baseItem2": {
    "subItem1Company": {
      "name": "Apple"
    },
    "subItem2Company": {
      "name": "Intel"
    }
  },
  "baseItem3": {}
}

I wish one of these expressions could work:
$..['/.*Bank/'].name
$..[?('/.*Bank/')].name
$..[?(@.key() =~ '/.*Bank/')].name

and as a result
[ "ABC", "ING", "JPMorgan"]

@yk-jemmic yk-jemmic changed the title Add RegExp to the path filtering Add RegEx to the path filtering Jul 21, 2023
@Iamhomkar
Copy link

+1

@SourabhKolekar
Copy link

any update on this? @yk-jemmic did you found any workaround?

@kerler
Copy link

kerler commented May 27, 2024

+1

@jeancafontalvo-pirani
Copy link

Hi, any update on this? Or workaround? ^-^

@He-Pin
Copy link

He-Pin commented Dec 17, 2024

we have implemented this, not sure if we can open source it.

@He-Pin
Copy link

He-Pin commented Dec 17, 2024

I just wrote about this in the jsonpath RFC repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants