0

以下是 REST 请求的响应,我的要求是验证名称节点是否包含“军事”且数量节点是否等于 500

[
      {
        "incentiveId":11791331,
        "autoApplied":null,
        "name":"Toyota US Lease Loyalty - National excl. Southeast",
        "amount":500,
        "expirationDate":"2018-07-09",
        "minimumTerm":null,
        "maximumTerm":null,
        "groupAffiliation":null,
        "previousOwnership":"Lease Loyalty"
      },
      {
        "incentiveId":11990139,
        "name":"Toyota US Military Appreciation - National excl. Southeast",
        "amount":1000,
        "expirationDate":"2018-12-31",
        "groupAffiliation":"Military",
        "previousOwnership":null
      }
    ]

我在我的项目中使用 REST Assured IO API。你能帮我编写这个要求吗?

4

1 回答 1

0

您有多种选择,但首选的是:

  • 在单独的类中将 JSON 映射到 PoJo(Java 对象)。然后将 JSON 反序列化为对象数组并断言这些对象值。

  • 使用 RestAssured jsonPath 方法获取使用 jsonPath 的实际值。

希望这可以帮助。

于 2018-05-31T13:39:09.687 回答