0

My HTTP request returns an array similar to

[
{"id":"1", "data":"abc"},
{"id":"2", "data":"def"},
{"id":"3", "data":"ghi"}
]

As an input for a ForEach Controller I'm trying to extract the ids of above result into an array using a JSON Path Extractor with a Path expression of $..id. I'm expecting to get something similar to ["1", "2","3"] but the output I get is

ids=3
ids_matchNr=3

It appears that the JSON Path Extractor only matches/extracts the last occurrence of id instead of collecting all occurrences of the id values and adding them to an aray.

The same expression and data return the expected ["1", "2","3"] result array in jsonpath.curiousconcept.com so the expression seems to be correct.

Am I doing something wrong or is this a bug in the JSON Path Extractor?

Below are some screen prints for a little test Input Array Declaration

JSON Extractor

Debug Output

1 Answer 1

1

I cannot reproduce your issue:

  1. JSON Extractor

    JMeter JSON Extractor

  2. JSON Path Extractor

    JMeter JSON Path Extractor

So double check you are using the latest version of JMeter and JSON Path Extractor, the latter one can be upgraded using JMeter Plugins Manager

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks @Dmitri-T for the quick response. I Added a some screen prints of the test I created to the original post. The JMeter version I'm using is a fresh install which I downloaded just yesterday. Will check the JSON Path Extractor version in a little bit
I installed the plugins manager and and upgraded to the latest JSON Path Extractor but still got the same results. Do you mind pasting a screen shot of your Path Extractor setup?
Set "Match Numbers" to -1 and you should get the desired result. Just in case check out JMeter's JSON Path Extractor Plugin - Advanced Usage Scenarios article
Oh man, that's it!!! Thanks so much. I read the article over and over and only in the comments does somebody mention the -1. Anyway, all good now.
OMFG, thank you very much @DmitriT! I was hopeless after hours of searching on the web and docs and blogs about slicing an array with that json extractor and the only thing nobody mention is this -1! You saved me days of headaches

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.