1 year ago

#267073

test-img

swathi ravula

How to collect all values of a specific JSON key if it's in Map of Maps in JsonPath Rest Assured

I have a JSON of type

{
    "time": {
        "updated": "Mar 8, 2022 11:21:00 UTC",
        "updatedISO": "2022-03-08T11:21:00+00:00",
        "updateduk": "Mar 8, 2022 at 11:21 GMT"
    },
    "disclaimer": "This data was produced from the CoinDesk Bitcoin Price Index (USD). Non-USD currency data converted using hourly conversion rate from openexchangerates.org",
    "chartName": "Bitcoin",
    "bpi": {
        "USD": {
            "code": "USD",
            "symbol": "$",
            "rate": "38,847.2041",
            "description": "United States Dollar",
            "rate_float": 38847.2041
        },
        "GBP": {
            "code": "GBP",
            "symbol": "£",
            "rate": "29,605.7650",
            "description": "British Pound Sterling",
            "rate_float": 29605.765
        },
        "EUR": {
            "code": "EUR",
            "symbol": "€",
            "rate": "35,645.1844",
            "description": "Euro",
            "rate_float": 35645.1844
        }
    }
}

I wanted to get all the values of the rate which are higher than 3000. I tried in below ways

List rateValue =  jsonPath.getList("bpi.findAll{it->it.[\*].rate_float> 3000}");
 and
List rateValue = jsonPath.getList("bpi.[\*].findAll{it->it.rate_float> 3000}");

Notes: I only wanted to use JSONPath

java

rest-assured

rest-assured-jsonpath

0 Answers

Your Answer

Accepted video resources