如何使用 Rest Assured 从列表中获取值?

How to get the value from a List using Rest Assured?

我正在尝试使用 Rest Assured 为 studenId=123 获取 courseNumber 的第一个值。

当我使用

.body("students.courseList.courseNumber[0]",equalTo(1000000000))

我得到:

Expected: <1000000000>
Actual: [1000000000, 1000000001, 1000000002, 1000000003, ...........]

studentId 123 有超过 10 个 courseList。 也可以使用正则表达式从 JSON 响应中获取特定元素,或者当我有几千行 JSON 响应时如何获取元素的路径。

示例响应 -

        {
            "students": [
                 {
                    "studentId": "ABC",
                    "studentName": "Abcd Abcd",
                    "courseDescription": "AAJSHKJASSJAK LASNLKASA KJk;;K K;;KK;K;KL;K;",
                    "creditRemaining": 100,
                    "classStartDate": "20191220"
                },
                {
                    "studentId": "123",
                    "studentName": "DEFG, VBNH",
                    "courseDescription": "AAJSHKJASSJAK LASNLKASA KJk;;K K;;KK;K;KL;K;",
                    "classSchedule": 2,
                    "classStartDate": "20191220",
                    "slotsRemaining": 10,
                    "courseList": [
                        {
                            "courseNumber": 1000000000,
                            "courseName": "Chemistry",
                            "courseInstructor": "HGJ IOUIOU"
                            "courseCity": "New York",
                            "courseLevel": 100,
                            "description": "GJKJLKJLafgdhgf ljkllklk klyiyy mnbbnkljlkj 
       yttiuyuyuyoyo 
                         jhlkjkljkl"},
                    {
                        "courseNumber": 1000000001,
                        "courseName": "History",
                        "courseInstructor": "HGJ IOUIOU"
                        "courseCity": "New York",
                        "courseLevel": 100,
                        "description": "GJKJLKJLafgdhgf ljkllklk klyiyy mnbbnkljlkj yttiuyuyuyoyo 
                         jhlkjkljkl"},

        ]
        }
students.courseList.courseNumber[0][0] --> will give 1000000000

students.courseList.courseNumber[0][1] --> will give 1000000001