@Test public void decodeTextWebSocketFrameSimpleString() throws Exception { final TextWebSocketFrame frame = new TextWebSocketFrame("\"test\""); final String[] decode = JsonUtil.decode(frame); assertThat(decode.length, is(1)); assertThat(decode[0], equalTo("test")); frame.release(); }
@SuppressWarnings("resource") public static String[] decode(final TextWebSocketFrame frame) throws IOException { final ByteBuf content = frame.content(); if (content.readableBytes() == 0) { return EMPTY_STRING_ARRAY; } final ByteBufInputStream byteBufInputStream = new ByteBufInputStream(content); final byte firstByte = content.getByte(0); if (firstByte == '[') { return MAPPER.readValue(byteBufInputStream, String[].class); } else if (firstByte == '{') { return new String[] { content.toString(CharsetUtil.UTF_8) }; } else { return new String[] { MAPPER.readValue(byteBufInputStream, String.class) }; } }
JsonUtil { @SuppressWarnings("resource") public static String[] decode(final TextWebSocketFrame frame) throws IOException { final ByteBuf content = frame.content(); if (content.readableBytes() == 0) { return EMPTY_STRING_ARRAY; } final ByteBufInputStream byteBufInputStream = new ByteBufInputStream(content); final byte firstByte = content.getByte(0); if (firstByte == '[') { return MAPPER.readValue(byteBufInputStream, String[].class); } else if (firstByte == '{') { return new String[] { content.toString(CharsetUtil.UTF_8) }; } else { return new String[] { MAPPER.readValue(byteBufInputStream, String.class) }; } } }
JsonUtil { @SuppressWarnings("resource") public static String[] decode(final TextWebSocketFrame frame) throws IOException { final ByteBuf content = frame.content(); if (content.readableBytes() == 0) { return EMPTY_STRING_ARRAY; } final ByteBufInputStream byteBufInputStream = new ByteBufInputStream(content); final byte firstByte = content.getByte(0); if (firstByte == '[') { return MAPPER.readValue(byteBufInputStream, String[].class); } else if (firstByte == '{') { return new String[] { content.toString(CharsetUtil.UTF_8) }; } else { return new String[] { MAPPER.readValue(byteBufInputStream, String.class) }; } } private  JsonUtil(); }
JsonUtil { @SuppressWarnings("resource") public static String[] decode(final TextWebSocketFrame frame) throws IOException { final ByteBuf content = frame.content(); if (content.readableBytes() == 0) { return EMPTY_STRING_ARRAY; } final ByteBufInputStream byteBufInputStream = new ByteBufInputStream(content); final byte firstByte = content.getByte(0); if (firstByte == '[') { return MAPPER.readValue(byteBufInputStream, String[].class); } else if (firstByte == '{') { return new String[] { content.toString(CharsetUtil.UTF_8) }; } else { return new String[] { MAPPER.readValue(byteBufInputStream, String.class) }; } } private  JsonUtil(); @SuppressWarnings("resource") static String[] decode(final TextWebSocketFrame frame); static String[] decode(final String content); static String encode(final String content); }
JsonUtil { @SuppressWarnings("resource") public static String[] decode(final TextWebSocketFrame frame) throws IOException { final ByteBuf content = frame.content(); if (content.readableBytes() == 0) { return EMPTY_STRING_ARRAY; } final ByteBufInputStream byteBufInputStream = new ByteBufInputStream(content); final byte firstByte = content.getByte(0); if (firstByte == '[') { return MAPPER.readValue(byteBufInputStream, String[].class); } else if (firstByte == '{') { return new String[] { content.toString(CharsetUtil.UTF_8) }; } else { return new String[] { MAPPER.readValue(byteBufInputStream, String.class) }; } } private  JsonUtil(); @SuppressWarnings("resource") static String[] decode(final TextWebSocketFrame frame); static String[] decode(final String content); static String encode(final String content);  }