jmeter 无法在使用json提取器提取值期间删除空值

zazmityj  于 2023-06-23  发布在  其他
关注(0)|答案(1)|浏览(153)

“id”:23751775{ },“id”:null,“id”:null,“id”:23751567
需要用json提取器提取不为空的id,并保留空值,以便我可以使用其他值以备将来使用。我尝试了多个正则表达式,但没有成功

e0bqpujr

e0bqpujr1#

在没有看到JSON的情况下,很难提供全面的答案,但理论上,您可以使用Filter Operator忽略不需要的值的匹配。
例如,使用JSON:

{
  "store": {
    "book": [
      {
        "id": 1,
        "category": "reference",
        "author": "Nigel Rees",
        "title": "Sayings of the Century",
        "price": 8.95
      },
      {
        "id": 2,
        "category": "fiction",
        "author": "Evelyn Waugh",
        "title": "Sword of Honour",
        "price": 12.99
      },
      {
        "id": null,
        "category": "fiction",
        "author": "Herman Melville",
        "title": "Moby Dick",
        "isbn": "0-553-21311-3",
        "price": 8.99
      },
      {
        "id": 3,
        "category": "fiction",
        "author": "J. R. R. Tolkien",
        "title": "The Lord of the Rings",
        "isbn": "0-395-19395-8",
        "price": 22.99
      }
    ],
    "bicycle": {
      "color": "red",
      "price": 19.95
    }
  },
  "expensive": 10
}

这个JSONPath表达式
您可以看到只有3个匹配被返回,id属性有其各自的值:

当条件不存在时,它会给予你4个匹配项,其中一个值为空:

更多信息:How to Use the JSON Extractor For Testing

相关问题