@Test void testDecodeJsonUtf16() throws IOException { assertEquals( "bob", jsonDecoder.decode( Unpooled.copiedBuffer("{\"name\":\"bob\"}", Charset.forName("UTF-16")), "application/json; charset=utf-16", Person.class) .name); }
@SuppressWarnings("unchecked") @Override public <T> T decode(ByteBuf body, CharSequence contentType, Class<T> clazz) throws IOException { try (InputStreamReader reader = new InputStreamReader( new ByteBufInputStream(body), HttpUtil.getCharset(contentType, Charset.forName("UTF-8")))) { if (MessageLite.class.isAssignableFrom(clazz)) { MessageLite message = protoDefaultInstances.get(clazz); Message.Builder builder = (Message.Builder) message.toBuilder(); JsonFormat.parser().merge(reader, builder); return (T) builder.build(); } return mapper.readValue(reader, clazz); } }
JsonDecoder implements Decoder { @SuppressWarnings("unchecked") @Override public <T> T decode(ByteBuf body, CharSequence contentType, Class<T> clazz) throws IOException { try (InputStreamReader reader = new InputStreamReader( new ByteBufInputStream(body), HttpUtil.getCharset(contentType, Charset.forName("UTF-8")))) { if (MessageLite.class.isAssignableFrom(clazz)) { MessageLite message = protoDefaultInstances.get(clazz); Message.Builder builder = (Message.Builder) message.toBuilder(); JsonFormat.parser().merge(reader, builder); return (T) builder.build(); } return mapper.readValue(reader, clazz); } } }
JsonDecoder implements Decoder { @SuppressWarnings("unchecked") @Override public <T> T decode(ByteBuf body, CharSequence contentType, Class<T> clazz) throws IOException { try (InputStreamReader reader = new InputStreamReader( new ByteBufInputStream(body), HttpUtil.getCharset(contentType, Charset.forName("UTF-8")))) { if (MessageLite.class.isAssignableFrom(clazz)) { MessageLite message = protoDefaultInstances.get(clazz); Message.Builder builder = (Message.Builder) message.toBuilder(); JsonFormat.parser().merge(reader, builder); return (T) builder.build(); } return mapper.readValue(reader, clazz); } }  }
JsonDecoder implements Decoder { @SuppressWarnings("unchecked") @Override public <T> T decode(ByteBuf body, CharSequence contentType, Class<T> clazz) throws IOException { try (InputStreamReader reader = new InputStreamReader( new ByteBufInputStream(body), HttpUtil.getCharset(contentType, Charset.forName("UTF-8")))) { if (MessageLite.class.isAssignableFrom(clazz)) { MessageLite message = protoDefaultInstances.get(clazz); Message.Builder builder = (Message.Builder) message.toBuilder(); JsonFormat.parser().merge(reader, builder); return (T) builder.build(); } return mapper.readValue(reader, clazz); } }  CharSequence mediaType(); @SuppressWarnings("unchecked") @Override T decode(ByteBuf body, CharSequence contentType, Class<T> clazz); }
JsonDecoder implements Decoder { @SuppressWarnings("unchecked") @Override public <T> T decode(ByteBuf body, CharSequence contentType, Class<T> clazz) throws IOException { try (InputStreamReader reader = new InputStreamReader( new ByteBufInputStream(body), HttpUtil.getCharset(contentType, Charset.forName("UTF-8")))) { if (MessageLite.class.isAssignableFrom(clazz)) { MessageLite message = protoDefaultInstances.get(clazz); Message.Builder builder = (Message.Builder) message.toBuilder(); JsonFormat.parser().merge(reader, builder); return (T) builder.build(); } return mapper.readValue(reader, clazz); } }  CharSequence mediaType(); @SuppressWarnings("unchecked") @Override T decode(ByteBuf body, CharSequence contentType, Class<T> clazz);  }