You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to capture a specific slice of an array from an API response using JSONPath in Insomnia, but I haven't been successful so far.
Here’s what I’m trying to achieve: I want to extract a subset of elements from an array in the response. For example, I want to capture elements 40 to 45 from an array named mydata.
Here are some of the JSONPath expressions I’ve tried:
$..mydata[40,45]
$..mydata[40:45]
$..mydata[40:45:1]
Unfortunately, none of these worked. I did notice that using something like $..mydata[40,41,42] returns a list of the specified elements, but I haven’t been able to make a range or slice work.
From my understanding, this should be a valid use case for JSONPath based on references like:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I'm trying to capture a specific slice of an array from an API response using JSONPath in Insomnia, but I haven't been successful so far.
Here’s what I’m trying to achieve: I want to extract a subset of elements from an array in the response. For example, I want to capture elements 40 to 45 from an array named mydata.
Here are some of the JSONPath expressions I’ve tried:
$..mydata[40,45]
$..mydata[40:45]
$..mydata[40:45:1]
Unfortunately, none of these worked. I did notice that using something like $..mydata[40,41,42] returns a list of the specified elements, but I haven’t been able to make a range or slice work.
From my understanding, this should be a valid use case for JSONPath based on references like:
https://goessner.net/articles/JsonPath/index.html#e2
https://github.com/json-path/JsonPath
https://docs.oracle.com/cd/E60058_01/PDF/8.0.8.x/8.0.8.0.0/PMF_HTML/JsonPath_Expressions.htm
Is there a specific syntax or limitation in Insomnia’s JSONPath implementation that I should be aware of? Or is there another way to achieve this?
Any help or guidance would be greatly appreciated!
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions