简体   繁体   中英

REST-assured | How to get a string value based on matching critera using JSONpath

I need to get count value based on matching critera using REST Assured Jsonpath

I tried the following but its not working:

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" }] }
]

Please try the below, it will return 456

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM