Do not Escape HTML in JSON
See original GitHub issueDescribe the bug
My local http server replies to the endpoint below with {"data":{"test":"it's a && b || c + 1!?"},"status":"success"}
and the HTTP header Content-Type"
is set to "application/json;charset=utf-8"
. However, Unirest doesn’t decode the answer with UTF-8
.
To Reproduce Here is my code:
public static void main(String[] args) throws Exception{
Unirest.config().verifySsl(false);
HttpResponse<JsonNode> jsonNode = Unirest.get("https://localhost:8443/status").asJson();
System.out.println(jsonNode.getBody());
}
Which prints {"data":{"test":"it\u0027s a \u0026\u0026 b || c + 1!?"},"status":"success"}
I am not using HTTP compression or anything else that I could think of that could break this. If I extract a HttpResponse<byte[]>
instead and decode it with UTF-8
manually I obtain the expected result.
Expected behavior
Decode the answer correctly and get
{“data”:{“test”:“it’s a && b || c + 1!?”},“status”:“success”}
Environmental Data:
- Java Version: 11.0.1
Additional context The artifact I am using is
<dependency>
<groupId>com.konghq</groupId>
<artifactId>unirest-java</artifactId>
<version>3.11.01</version>
</dependency>
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Complete in 3.11.02
Could be up to 10 MB of hexadecimal data, which would be highly compressable.