You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note the extra colons after ErrorCode and ErrorMsg. These extra colons are valid Json, as they are simply part of their strings, and any prettyprinter on the web will render it correctly as:
java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" because the return value of "io.restassured.internal.common.path.ObjectConverter.convertObjectTo(Object, java.lang.Class)" is null
Removing the extra colons from jsonString itself clears the error.
Not sure why restassured has a problem with this valid Json.
The text was updated successfully, but these errors were encountered:
I encountered a queryable Json object on the web similar to:
{"message":{"ErrorCode:":0,"ErrorMsg:":"Success"}}
Note the extra colons after ErrorCode and ErrorMsg. These extra colons are valid Json, as they are simply part of their strings, and any prettyprinter on the web will render it correctly as:
{
"message": {
"ErrorCode:": 0,
"ErrorMsg:": "Success"
}
}
However, after querying this object with restassured and extracting the response body to jsonString, the following code:
JsonPath jsonPath = new JsonPath(jsonString);
Assert.assertEquals(jsonPath.getInt("message.ErrorCode:"), 0);
throws error in the Assert statement:
java.lang.IllegalArgumentException: Invalid JSON expression
Removing the colon from the Assert statement:
Assert.assertEquals(jsonPath.getInt("message.ErrorCode"), 0);
and rerunning then throws error:
java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" because the return value of
"io.restassured.internal.common.path.ObjectConverter.convertObjectTo(Object, java.lang.Class)" is null
Removing the extra colons from jsonString itself clears the error.
Not sure why restassured has a problem with this valid Json.
The text was updated successfully, but these errors were encountered: