Anyone who can help me solve this.
I get:
java.lang.IllegalArgumentException: Invalid JSON expression:
Script1.groovy: 1: unexpected token: ] @ line 1, column 30.
$[*]
^
My code:
List<Browser> browsers =
given()
.log().ifValidationFails()
.accept("application/json; charset=utf-8")
.when()
.get("/jobs")
.then()
.statusCode(HttpStatus.SC_OK)
.body("size()", greaterThan(0))
.extract().body().jsonPath().getList("$[*]", Browser.class);
My json: (from http://localhost/browsers)
[
{
"browser_version":"16.0",
"browser":"firefox",
"os_version":"8",
"os":"Windows",
"device":null
},
{
"browser_version":"17.0",
"browser":"firefox",
"os_version":"8",
"os":"Windows",
"device":null
},
{
"browser_version":"18.0",
"browser":"firefox",
"os_version":"8",
"os":"Windows",
"device":null
}
]
--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Thank you for your reply. It was very helpful.If I use $ I get java.lang.ClassCastException: Cannot convert class java.util.HashMap to class se.svt.test.screenshots.model.Browser.
--
I solved the issue. Thank you very much for your help. It seems like the problem was that the test run before the context of the server was loaded. So your solution was correct.
--