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

Does jmespath support "substring" function #77

Open
zacard-orc opened this issue Nov 9, 2021 · 6 comments
Open

Does jmespath support "substring" function #77

zacard-orc opened this issue Nov 9, 2021 · 6 comments

Comments

@zacard-orc
Copy link

hello, i met a problem ,to use different char idx to switch the business. eg

"01234abc" : extract if ab => way to 1
"01234efg" : extract if ef => way to 2
"01234mno" : extract if mn=> way to 3

I browse the official doc and not found any method to support this.

Dose anybody met the same problem and how to resolve it ?

@darrenmothersele
Copy link

Hi, sorry - I don't understand your description of what you are trying to do. Can you give an example (or two) of expected input and expected output?

@jarrodek
Copy link

jarrodek commented Jun 4, 2022

I have a similar issue. I would like to have a built-in function that performs a similar to String.prototype.substring() operation.

For given input:

{
  "foo": "bar"
}

I would like to run an expression like this:

// in JS the substring has a signature of substring(indexStart, indexEnd)
.search(..., 'foo | substring(0, 1)') // ba
.search(..., 'foo | substring(0, 2)') // bar
.search(..., 'foo | substring(0)') // bar
.search(..., 'foo | substring(1)') // ar

or by using slice expression

.search(..., 'foo[0:1]') // ba
.search(..., 'foo[0:2]') // bar
.search(..., 'foo[0]') // bar
.search(..., 'foo[1]') // ar

@springcomp
Copy link

springcomp commented Aug 9, 2022

@zacard-orc we are standardizing a host of string manipulation functions in JMESPath Community. Substrings will be achieved using the existing slice-expression syntax.

@jpmckinney
Copy link

JEP: jmespath/jmespath.jep#5

@springcomp
Copy link

springcomp commented Mar 8, 2023

JEP: jmespath/jmespath.jep#5

Yep ! that’s exactly where I took this piece of feedback when brainstorming the list of features to include in the next version of JMESPath. Incidentally, @glenveegee has created an awesome port of JMESPath to TypeScript but this does not seem to be maintained any longer.

So, while preparing a version for JMESPath Community, I am proposing all my changes upstream anyway. I hope to find an official maintainer then.

@glenveegee
Copy link

@springcomp I'm updating it as we speak. Just been busy.

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