0

I have a JSON output like this:

{
    "items": [
        {
            "id": "1",
            "name": "Anna",
            "values": [
                {
                    "code": "Latin",
                    "grade": 1
                },
                {
                    "code": "Maths",
                    "grade": 5
                }
            ]
        },
        {
            "id": "2",
            "name": "Mark",
            "values": [
                {
                    "code": "Latin",
                    "grade": 5
                },
                {
                    "code": "Maths",
                    "grade": 5
                }
            ]
        }
    ]
}

I need to get field values for "name": "Anna". I am getting RestAssured Response and would like to use my beans to do that, but I can also use jsonPath() or jsonObject(), but I don't know how. I searched many topics but did not find anything.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
jacob1989
  • 15
  • 3
  • Many JSON query libraries can do that. E.g. library _Josson_, the expression for your solution is `items[name='Anna'].values` which produces a _Jackson_ `JsonNode`. – Raymond Choi Jan 18 '23 at 14:05
  • Does this answer your question? [Using JSONpath in REST ASSURED java want to extract the data which are in array](https://stackoverflow.com/questions/72011011/using-jsonpath-in-rest-assured-java-want-to-extract-the-data-which-are-in-array) – knittl Jan 18 '23 at 16:57

0 Answers0