Skip to content

Commit

Permalink
Merge pull request #21 from kintone/fix-json-request-encoding
Browse files Browse the repository at this point in the history
fix: encode JSON requests in UTF-8
  • Loading branch information
aoking authored Mar 12, 2021
2 parents 68b123d + 4233ef5 commit 7829bfa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/main/java/com/kintone/client/InternalClientImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,7 @@ private HttpUriRequest createJsonRequest(KintoneHttpMethod method, String path,
if (body == null) {
return createRequest(method, path, null, null);
} else {
HttpEntity entity =
new ByteArrayEntity(mapper.format(body).getBytes(), ContentType.APPLICATION_JSON);
HttpEntity entity = new ByteArrayEntity(mapper.format(body), ContentType.APPLICATION_JSON);
return createRequest(method, path, ContentType.APPLICATION_JSON.getMimeType(), entity);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/kintone/client/JsonMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ private static ObjectMapper createObjectMapper() {
.build();
}

String format(Object obj) {
byte[] format(Object obj) {
try {
return mapper.writeValueAsString(obj);
return mapper.writeValueAsBytes(obj);
} catch (JsonProcessingException e) {
throw new KintoneRuntimeException("Failed to format request JSON", e);
}
Expand Down

0 comments on commit 7829bfa

Please sign in to comment.