class JsonRowSerializer implements RowSerializer {

    @Override
    public String serialize(byte[] rowKey, ResultCell[] cells) {
        final StringBuilder jsonBuilder = new StringBuilder();
        jsonBuilder.append("{");

        final String row = new String(rowKey, charset);
        jsonBuilder.append("\"row\":")
                .append("\"")
                .append(StringEscapeUtils.escapeJson(row))
                .append("\"");

        jsonBuilder.append(", \"cells\": {");
        int i = 0;
        for (final ResultCell cell : cells) {
            final String cellFamily = new String(cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength(), charset);
            final String cellQualifier = new String(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength(), charset);

            if (i > 0) {
                jsonBuilder.append(", ");
            }
            jsonBuilder.append("\"")
                    .append(StringEscapeUtils.escapeJson(cellFamily))
                    .append(":")
                    .append(StringEscapeUtils.escapeJson(cellQualifier))
                    .append("\":\"")
                    .append(StringEscapeUtils.escapeJson(new String(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength(), charset)))
                    .append("\"");
            i++;
        }

        jsonBuilder.append("}}");
        return jsonBuilder.toString();
    }

    public  JsonRowSerializer(final Charset charset);

}