@Test public void testSerializeRegular() throws IOException { final ByteArrayOutputStream out = new ByteArrayOutputStream(); final RowSerializer rowSerializer = new JsonFullRowSerializer(StandardCharsets.UTF_8, StandardCharsets.UTF_8); rowSerializer.serialize(rowKey, cells, out); final String json = out.toString(StandardCharsets.UTF_8.name()); Assert.assertEquals("{\"row\":\"row1\", \"cells\": [" + "{\"fam\":\"" + FAM1 + "\",\"qual\":\"" + QUAL1 + "\",\"val\":\"" + VAL1 + "\",\"ts\":" + TS1 + "}, " + "{\"fam\":\"" + FAM2 + "\",\"qual\":\"" + QUAL2 + "\",\"val\":\"" + VAL2 + "\",\"ts\":" + TS2 + "}]}", json); }
@Override public String serialize(byte[] rowKey, ResultCell[] cells) { final String rowId = RowSerializerUtil.getRowId(rowKey, decodeCharset, base64encode); final StringBuilder jsonBuilder = new StringBuilder(); jsonBuilder.append("{"); jsonBuilder.append("\"row\":"); appendString(jsonBuilder, rowId, base64encode); jsonBuilder.append(", \"cells\": ["); int i = 0; for (final ResultCell cell : cells) { final String cellFamily = RowSerializerUtil.getCellFamily(cell, decodeCharset, base64encode); final String cellQualifier = RowSerializerUtil.getCellQualifier(cell, decodeCharset, base64encode); final String cellValue = RowSerializerUtil.getCellValue(cell, decodeCharset, base64encode); if (i > 0) { jsonBuilder.append(", "); } jsonBuilder.append("{"); jsonBuilder.append("\"fam\":"); appendString(jsonBuilder, cellFamily, base64encode); jsonBuilder.append(",\"qual\":"); appendString(jsonBuilder, cellQualifier, base64encode); jsonBuilder.append(",\"val\":"); appendString(jsonBuilder, cellValue, base64encode); jsonBuilder.append(",\"ts\":"); jsonBuilder.append(String.valueOf(cell.getTimestamp())); jsonBuilder.append("}"); i++; } jsonBuilder.append("]"); jsonBuilder.append("}"); return jsonBuilder.toString(); }
JsonFullRowSerializer implements RowSerializer { @Override public String serialize(byte[] rowKey, ResultCell[] cells) { final String rowId = RowSerializerUtil.getRowId(rowKey, decodeCharset, base64encode); final StringBuilder jsonBuilder = new StringBuilder(); jsonBuilder.append("{"); jsonBuilder.append("\"row\":"); appendString(jsonBuilder, rowId, base64encode); jsonBuilder.append(", \"cells\": ["); int i = 0; for (final ResultCell cell : cells) { final String cellFamily = RowSerializerUtil.getCellFamily(cell, decodeCharset, base64encode); final String cellQualifier = RowSerializerUtil.getCellQualifier(cell, decodeCharset, base64encode); final String cellValue = RowSerializerUtil.getCellValue(cell, decodeCharset, base64encode); if (i > 0) { jsonBuilder.append(", "); } jsonBuilder.append("{"); jsonBuilder.append("\"fam\":"); appendString(jsonBuilder, cellFamily, base64encode); jsonBuilder.append(",\"qual\":"); appendString(jsonBuilder, cellQualifier, base64encode); jsonBuilder.append(",\"val\":"); appendString(jsonBuilder, cellValue, base64encode); jsonBuilder.append(",\"ts\":"); jsonBuilder.append(String.valueOf(cell.getTimestamp())); jsonBuilder.append("}"); i++; } jsonBuilder.append("]"); jsonBuilder.append("}"); return jsonBuilder.toString(); } }
JsonFullRowSerializer implements RowSerializer { @Override public String serialize(byte[] rowKey, ResultCell[] cells) { final String rowId = RowSerializerUtil.getRowId(rowKey, decodeCharset, base64encode); final StringBuilder jsonBuilder = new StringBuilder(); jsonBuilder.append("{"); jsonBuilder.append("\"row\":"); appendString(jsonBuilder, rowId, base64encode); jsonBuilder.append(", \"cells\": ["); int i = 0; for (final ResultCell cell : cells) { final String cellFamily = RowSerializerUtil.getCellFamily(cell, decodeCharset, base64encode); final String cellQualifier = RowSerializerUtil.getCellQualifier(cell, decodeCharset, base64encode); final String cellValue = RowSerializerUtil.getCellValue(cell, decodeCharset, base64encode); if (i > 0) { jsonBuilder.append(", "); } jsonBuilder.append("{"); jsonBuilder.append("\"fam\":"); appendString(jsonBuilder, cellFamily, base64encode); jsonBuilder.append(",\"qual\":"); appendString(jsonBuilder, cellQualifier, base64encode); jsonBuilder.append(",\"val\":"); appendString(jsonBuilder, cellValue, base64encode); jsonBuilder.append(",\"ts\":"); jsonBuilder.append(String.valueOf(cell.getTimestamp())); jsonBuilder.append("}"); i++; } jsonBuilder.append("]"); jsonBuilder.append("}"); return jsonBuilder.toString(); } JsonFullRowSerializer(final Charset decodeCharset, final Charset encodeCharset);  JsonFullRowSerializer(final Charset decodeCharset, final Charset encodeCharset, final boolean base64encode); }
JsonFullRowSerializer implements RowSerializer { @Override public String serialize(byte[] rowKey, ResultCell[] cells) { final String rowId = RowSerializerUtil.getRowId(rowKey, decodeCharset, base64encode); final StringBuilder jsonBuilder = new StringBuilder(); jsonBuilder.append("{"); jsonBuilder.append("\"row\":"); appendString(jsonBuilder, rowId, base64encode); jsonBuilder.append(", \"cells\": ["); int i = 0; for (final ResultCell cell : cells) { final String cellFamily = RowSerializerUtil.getCellFamily(cell, decodeCharset, base64encode); final String cellQualifier = RowSerializerUtil.getCellQualifier(cell, decodeCharset, base64encode); final String cellValue = RowSerializerUtil.getCellValue(cell, decodeCharset, base64encode); if (i > 0) { jsonBuilder.append(", "); } jsonBuilder.append("{"); jsonBuilder.append("\"fam\":"); appendString(jsonBuilder, cellFamily, base64encode); jsonBuilder.append(",\"qual\":"); appendString(jsonBuilder, cellQualifier, base64encode); jsonBuilder.append(",\"val\":"); appendString(jsonBuilder, cellValue, base64encode); jsonBuilder.append(",\"ts\":"); jsonBuilder.append(String.valueOf(cell.getTimestamp())); jsonBuilder.append("}"); i++; } jsonBuilder.append("]"); jsonBuilder.append("}"); return jsonBuilder.toString(); } JsonFullRowSerializer(final Charset decodeCharset, final Charset encodeCharset);  JsonFullRowSerializer(final Charset decodeCharset, final Charset encodeCharset, final boolean base64encode); @Override String serialize(byte[] rowKey, ResultCell[] cells); @Override void serialize(final byte[] rowKey, final ResultCell[] cells, final OutputStream out); }
JsonFullRowSerializer implements RowSerializer { @Override public String serialize(byte[] rowKey, ResultCell[] cells) { final String rowId = RowSerializerUtil.getRowId(rowKey, decodeCharset, base64encode); final StringBuilder jsonBuilder = new StringBuilder(); jsonBuilder.append("{"); jsonBuilder.append("\"row\":"); appendString(jsonBuilder, rowId, base64encode); jsonBuilder.append(", \"cells\": ["); int i = 0; for (final ResultCell cell : cells) { final String cellFamily = RowSerializerUtil.getCellFamily(cell, decodeCharset, base64encode); final String cellQualifier = RowSerializerUtil.getCellQualifier(cell, decodeCharset, base64encode); final String cellValue = RowSerializerUtil.getCellValue(cell, decodeCharset, base64encode); if (i > 0) { jsonBuilder.append(", "); } jsonBuilder.append("{"); jsonBuilder.append("\"fam\":"); appendString(jsonBuilder, cellFamily, base64encode); jsonBuilder.append(",\"qual\":"); appendString(jsonBuilder, cellQualifier, base64encode); jsonBuilder.append(",\"val\":"); appendString(jsonBuilder, cellValue, base64encode); jsonBuilder.append(",\"ts\":"); jsonBuilder.append(String.valueOf(cell.getTimestamp())); jsonBuilder.append("}"); i++; } jsonBuilder.append("]"); jsonBuilder.append("}"); return jsonBuilder.toString(); } JsonFullRowSerializer(final Charset decodeCharset, final Charset encodeCharset);  JsonFullRowSerializer(final Charset decodeCharset, final Charset encodeCharset, final boolean base64encode); @Override String serialize(byte[] rowKey, ResultCell[] cells); @Override void serialize(final byte[] rowKey, final ResultCell[] cells, final OutputStream out);  }