My Java - Jersey framework REST API makes a call to another service which returns the following JSON response. I have logged the response from the child service in my logs, and I can see that the value of ErrorMessage
contains a Unicode value like \u2019
instead of a single quote ('
).
{ "id": "SAMPLE", "version": 1, "status": { "lastReceivedError": { "ErrorDateTime": 1576588715, "ErrorCode": "TEST3200", "ErrorMessage": "We\u2019re sorry, the content is not available." } } }
I have to map these values into my model and return as a JSON as well. I used GSON to convert the above JSON string into an object. And mapped the values from that object into my response object. My final outgoing JSON response is like below, wherein the single quote is appearing as question mark (?
).
{
"MyResponse": {
"success": {
"lastReceivedError": {
"errorDateTime": "2019-12-17T13:18:35Z",
"errorCode": "TEST3200",
"errorMessage": "We?re sorry, the content is not available."
}
}
}
}
I believe there is something around encoding characters, but I am unable to fix the issue.