Jmeter JSONAssertion失败消息

时间:2019-10-29 21:09:43

标签: json performance jmeter httpresponse assertion

while performing the JSON Assertion using Jmeter , i get the following error.
  

预期在路径$ [“ body”]中找到具有属性$ ['id']的对象,但   找到“ net.minidev.json.JSONArray”。       根据JSON Provider.'com.jayway.jsonpath.spi.json.JsonSmartJsonProvider',这不是json对象。

please let me know what is the issue ?

1 个答案:

答案 0 :(得分:1)

该错误表示您的JsonPath查询与响应数据中的任何内容都不匹配。

例如,如果您有JSON之类的

{
  "body": [
    {
      "id": 28,
      "Title": "Sweden"
    },
    {
      "id": 56,
      "Title": "USA"
    },
    {
      "id": 89,
      "Title": "England"
    }
  ]
}

您将JSON Assertion配置为:

enter image description here

它将失败,因为JSON路径查询匹配> 1个元素:

enter image description here

为了测试28的值,您需要修改JSON路径查询以指向body JSON Array

中的第一个条目
$.body[0].id

enter image description here

更多信息:How to Use the JSON Plugin in JMeter