【问题标题】:JMeter JSON Extract to extract random value which is not nullJMeter JSON Extract 提取不为空的随机值
【发布时间】:2021-12-13 12:17:44
【问题描述】:

我正在使用下面的 JSON 提取器来提取随机 ItemID。它工作正常,但它也选择“空”值。有什么方法可以从下面的 json 中提取不为空的随机值(即下面示例中的 IT01 或 IT02)

JSON 路径表达式:$..ItemID 匹配号(0 表示随机):0**

[{ "ItemID": "空", "deliveryId": "1", }, { "ItemID": "IT01", "deliveryId": "2", }, { "ItemID": "IT02", "deliveryId": "3", } ] 谢谢

【问题讨论】:

    标签: jmeter jmeter-plugins


    【解决方案1】:
    1. 以下 JSONPath 表达式将为您提供所有不为空的 ItemID 属性值:

      $.[?(@.ItemID != "null")].ItemID
      

    2. 因此,您可以通过提供0 作为“匹配编号”来获得随机匹配。

    更多信息:

    【讨论】:

    • 感谢您的帮助,我的 JSON 格式如下,但它甚至返回 null 值。你能帮忙 $..[?(@.ItemID != null)].ItemID { "Items": [ { "ItemID": null, "deliveryId": "1", }, { "ItemID": "IT01 ", "deliveryId": "2", }, { "ItemID": "IT02", "deliveryId": "3", }, { "ItemID": "test", "deliveryId": "3", } ] }
    猜你喜欢
    • 2021-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多