简体   繁体   中英

How to find an object by a field value in Rest Assured?

I need to get to code of an array element that has field == firstName :

{
    "errors": [
        {
            "field": "firstName",
            "code": "NotBlank"
        },
        {
            "field": "lastName",
            "code": "NotBlank"
        }
    ]
}

With JsonPath, the way to do it is $.errors[?(@.field == firstName)].code . How do I do the same in Rest Assured with its GPath syntax?

还没有尝试过,但从我的头开始,这应该起作用:

errors.find { it.field == 'firstName' }.code

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