### Question:
JsonQualifierAndValueRowSerializer implements RowSerializer { @Override public String serialize(byte[] rowKey, ResultCell[] cells) { final StringBuilder jsonBuilder = new StringBuilder(); jsonBuilder.append("{"); int i = 0; for (final ResultCell cell : cells) { final String cellQualifier = RowSerializerUtil.getCellQualifier(cell, decodeCharset, base64encode); final String cellValue = RowSerializerUtil.getCellValue(cell, decodeCharset, base64encode); if (i > 0) { jsonBuilder.append(", "); } appendString(jsonBuilder, cellQualifier, base64encode); jsonBuilder.append(":"); appendString(jsonBuilder, cellValue, base64encode); i++; } jsonBuilder.append("}"); return jsonBuilder.toString(); } JsonQualifierAndValueRowSerializer(final Charset decodeCharset, final Charset encodeCharset);  JsonQualifierAndValueRowSerializer(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);  }### Answer:
@Test public void testSerializeRegular() throws IOException { final ByteArrayOutputStream out = new ByteArrayOutputStream(); final RowSerializer rowSerializer = new JsonQualifierAndValueRowSerializer(StandardCharsets.UTF_8, StandardCharsets.UTF_8); rowSerializer.serialize(rowKey, cells, out); final String json = out.toString(StandardCharsets.UTF_8.name()); Assert.assertEquals("{\"" + QUAL1 + "\":\"" + VAL1 + "\", \"" + QUAL2 + "\":\"" + VAL2 + "\"}", json); }
@Test public void testSerializeWithBase64() throws IOException { final ByteArrayOutputStream out = new ByteArrayOutputStream(); final RowSerializer rowSerializer = new JsonQualifierAndValueRowSerializer(StandardCharsets.UTF_8, StandardCharsets.UTF_8, true); rowSerializer.serialize(rowKey, cells, out); final String qual1Base64 = Base64.encodeBase64String(QUAL1.getBytes(StandardCharsets.UTF_8)); final String val1Base64 = Base64.encodeBase64String(VAL1.getBytes(StandardCharsets.UTF_8)); final String qual2Base64 = Base64.encodeBase64String(QUAL2.getBytes(StandardCharsets.UTF_8)); final String val2Base64 = Base64.encodeBase64String(VAL2.getBytes(StandardCharsets.UTF_8)); final String json = out.toString(StandardCharsets.UTF_8.name()); Assert.assertEquals("{\"" + qual1Base64 + "\":\"" + val1Base64 + "\", \"" + qual2Base64 + "\":\"" + val2Base64 + "\"}", json); }