Skip to content

Commit

Permalink
Avoid outputstream
Browse files Browse the repository at this point in the history
Signed-off-by: Paulo Lopes <pmlopes@gmail.com>
  • Loading branch information
pmlopes committed May 10, 2017
1 parent d9a38f3 commit 8888d0c
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions src/main/java/io/vertx/core/json/Json.java
Expand Up @@ -26,7 +26,6 @@

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.time.Instant;
import java.util.Base64;
Expand Down Expand Up @@ -75,17 +74,7 @@ public static String encode(Object obj) throws EncodeException {

public static Buffer encodeToBuffer(Object obj) throws EncodeException {
try {
final Buffer buffer = Buffer.buffer();

mapper.writeValue(new OutputStream() {
@Override
public void write(int b) throws IOException {
buffer.appendByte((byte) b);
}
}, obj);

return buffer;

return Buffer.buffer(mapper.writeValueAsBytes(obj));
} catch (Exception e) {
throw new EncodeException("Failed to encode as JSON: " + e.getMessage());
}
Expand Down

0 comments on commit 8888d0c

Please sign in to comment.