Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Split a JSON string value using JMESPath

Tags:

json

jmespath

I have a payload in a format similar to below:

{
  "year": "2022", 
  "cycle": "Aug", 
  "origin": {
    "file_location": "GDT Post-Distribution Manifest/Italy/Rome/2022/Aug/Italy Rome_202208241528.xlsx", 
    "protocol": "s3:"
  }
}

I want to check if the third element of the file_location is equal to something (in this case it is marked as Rome).
How do I gain access this element?

like image 932
user2772056 Avatar asked Aug 12 '26 20:08

user2772056


1 Answers

In order to achieve this, you would need to have some sort of functionality to split a string, which is, sadly, not something that exists in the language for the moment being.

There is a proposal to add the functionality, though: New function: array[string] split(string $separator, string $subject).

like image 58
β.εηοιτ.βε Avatar answered Aug 21 '26 17:08

β.εηοιτ.βε