Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jmeter JSon Extract multiple values

Tags:

json

jmeter

I am trying to extract multiple values from a JSON document through the JMETER JSON Extractor with the following expression: $..VoidTransactionReferenceNumber;$..CILAmount

However, I am unable to get desired response, which is the VoidTransactionReferenceNumber and CLIAmount.

The JSON document is:

{
    "VoidTransactionReferenceNumber": "23456", 
    "TransactionDTM": "2017-11-16T10:09:16.343Z", 
    "CardBalance": 2350,
    "CardSequenceNumber": 0,
    "CILAmount": 0,
    "AutoloadAmount": 0,
    "CardBlockState": false, 
    "VoidedAmount": 570, 
    "SalesReferenceNumber": "2051609371", 
    "VoidSalesReferenceNumber": "2051609371",
    "CardNumber": "3085220112345678"
}
like image 316
NinjaVoo Avatar asked Nov 30 '22 08:11

NinjaVoo


1 Answers

You need to provide the same amount of Default Values as for JSON Path Expresions and Variable Names.

  1. Add JSON Extractor as a child of the request which returns the above JSON
  2. Configure it as follows:

    • Variable names: VoidTransactionReferenceNumber;CILAmount
    • JSON Path Expressions: $.VoidTransactionReferenceNumber;$.CILAmount
    • Default values: NOT_FOUND; NOT_FOUND

      JMeter JSON Extractor

  3. As a result you will have the following JMeter Variables defined

    JMeter JSON Extractor Variables

  4. You will be able to refer them as ${VoidTransactionReferenceNumber} and ${CILAmount} where required.

More information: API Testing With JMeter and the JSON Extractor

like image 80
Dmitri T Avatar answered Dec 30 '22 06:12

Dmitri T