Home > Software design >  Extract only the first id from json (JMeter - JSON Extractor)
Extract only the first id from json (JMeter - JSON Extractor)

Time:11-03

I have a problem to extract only the first id from json using "JSON Extractor" in JMeter and will be thankful if someone help me.

Example json:

{
 "content" : [
   {
      "id": 1,
      "name":"John",
      "data" : {
          "id" : 101,
          "dataType" : "exampledata1" }
   },
   {
       "id": 2,
       "name":"Johnatan",
       "data" : {
           "id": 102,
           "dataType": "exampledata2"}
   }
}

My goal is to extract only first id values (1,2 .. etc).

With JSON Extractor - expression $..id and match no. -1, it extracts all the values, like:

id_1=1
id_2=101
id_3=2
id_4=102

I want:

id_1=1
id_2=2

Thank you in advance!

CodePudding user response:

.. is a enter image description here

More information: How to Use the JSON Extractor For Testing

  • Related