Jmeter JSon提取多个值

时间:2017-11-16 11:15:18

标签: json jmeter

我尝试使用以下表达式通过JMETER JSON Extractor从JSON文档中提取多个值:$..VoidTransactionReferenceNumber;$..CILAmount

但是,我无法获得所需的回复,即VoidTransactionReferenceNumberCLIAmount

JSON文档是:

{
    "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"
}

1 个答案:

答案 0 :(得分:9)

您需要提供与JSON Path Expresions和Variable Names相同数量的Default Values

  1. 添加JSON Extractor作为返回上述JSON
  2. 的请求的子代
  3. 按如下方式配置:

    • 变量名称:VoidTransactionReferenceNumber;CILAmount
    • JSON路径表达式:$.VoidTransactionReferenceNumber;$.CILAmount
    • 默认值:NOT_FOUND; NOT_FOUND

      JMeter JSON Extractor

  4. 因此,您将定义以下JMeter变量

    JMeter JSON Extractor Variables

  5. 您可以根据需要将其引荐为${VoidTransactionReferenceNumber}${CILAmount}

  6. 更多信息:API Testing With JMeter and the JSON Extractor