REST保证|如何使用JSONpath根据匹配的critera获取字符串值

时间:2019-10-03 17:28:04

标签: java rest-assured-jsonpath

我需要使用REST Assured Jsonpath根据匹配的critera获取计数值

我尝试了以下操作,但不起作用:

response().jsonPath().getString("{it.B == '456'}.B1.size()")

JSON:

[{ "A": "123", "A1": [{ "A11": "A111" }, { "A12": "A112" }, { "A13": "A113" }] },
{ "B": "456", "A1": [{ "B11": "B111" }, { "B12": "B112" }, { "B13": "B113" }, { "B14": "B114" }, { "B15": "B115" }] },
{ "C": "456", "A1": [{ "C11": "C111" }, { "C12": "C112" }, { "C13": "C113" }, { "C14": "C114" }, { "C15": "C115" }, { "C16": "C116" }] }
]

1 个答案:

答案 0 :(得分:0)

请尝试以下操作,它将返回456

response().jsonPath().getString("$.[1].B")