Problem using Jackon ObjectMapper to read a String created from a invalid JSON response
Here is the relevant snippet of the code:
Response response = request.get();
String responseAsString = response.readEntity(String.class);
ObjectMapper mapper = new ObjectMapper();
JsonNode responseNode = mapper.readTree(responseAsString);
When I run this code I get this exception: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('-' (code 45)): was expecting comma to separate OBJECT entries
Background on the problem: I am making a GET request and it is successfully responding. I then convert that response into a String so that I can then change it into a JsonNode and extract the parts I want. If I print out the responseAsString it looks like this:
{
"account": 123456789,
"balance": 5602,
"dateTime": 2017-06-15T03:29:00,
"token": "H77ABC0PPIQ"
}
I believe the issue has to due with how the response is formed since not all of the values are sent as Strings. Their types are as follows:
account: long
balance: long
dateTime: DateTime
token: String
I'm not sure how to convert the response to a Json object so that I can get individual values like the account number for example.
Any advice is appreciated. Thanks!