【问题标题】:how to use json feeders in gatling when the json structure is complicated当 json 结构复杂时如何在 gatling 中使用 json feeder
【发布时间】:2022-08-18 15:19:40
【问题描述】:

在场景中,如何为字段 \'location\' 和 \'ID\' 提供 EL$。

我尝试如下给出,但由于未为 \'ID\' 和 \'Location\' 定义属性而出现错误

 .body(
   StringBody(
     \"\"\"{\"name\": \"${name}\", \"Url\": \"${Url}\", “Product”: [ { \"ID\": \"${ID}\", \"location\": \"${location}\" } ] }\"\"\"
   )
  ).asJson

JSON:

[
   {
      \"name\":\"xyz\",
      \"url\":\"test1.com\",
      \"Product\":[
         {
            \"ID\":111111,
            \"location\":\"NewYork\"
         }
      ]
   },
   {
      \"name\":\"abc\",
      \"url\":\"test2.com\",
      \"Product\":[
         {
            \"ID\":22222,
            \"location\":\"Texas\"
         }
      ]
   }
]
  • 如果您不提供 JSON 的结构,将无法帮助您。
  • 下面是 JSON 结构的样子 { \"name\": "xyz", "url\": \"test1.com\", "Product": [ { \"ID\": 111111, \"location\ “: “纽约” } ] }
  • @Stéphane LANDELLE 非常感谢你。我在之前的评论中提供了结构
  • @Stéphane LANDELLE 这是我的 feeder 文件的样子: [ { \"name\": "xyz", "url\": \"test1.com\", "Product": [ { \"ID\": 111111 , \"location\": “NewYork” } ] }, { \"name\": “abc”, “url\": \"test2.com\", “Product”: [ { \"ID\": 22222, \"location\": “Texas” } ] } ] 当我尝试将 $ 用于字符串正文 i 中的 ID 和位置字段时,我遇到了未为 \'ID\' 和 \'Location\' 定义的问题

标签: gatling


【解决方案1】:

IDlocation 字段位于 Product 对象内,因此正确的加特林 EL 字符串将分别为 #{Product.ID}#{Product.location}

【讨论】:

    猜你喜欢
    • 2019-02-10
    • 2011-05-08
    • 2015-05-30
    • 2021-06-25
    • 2016-08-20
    • 2011-08-26
    • 1970-01-01
    • 2018-12-12
    • 1970-01-01
    相关资源
    最近更新 更多