@@ -0,0 +1,3568 @@
+package com.csforge.sstable.json;%0A%0Aimport java.io.IOException;%0Aimport java.io.OutputStream;%0Aimport java.io.OutputStreamWriter;%0Aimport java.util.stream.Stream;%0A%0Aimport com.csforge.reader.Partition;%0Aimport com.google.gson.Gson;%0Aimport com.google.gson.GsonBuilder;%0Aimport com.google.gson.stream.JsonWriter;%0Aimport org.apache.cassandra.config.CFMetaData;%0Aimport org.apache.cassandra.db.rows.RangeTombstoneMarker;%0Aimport org.apache.cassandra.db.rows.Row;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Apublic class JsonTransformer %7B%0A%0A    private static final Logger logger = LoggerFactory.getLogger(JsonTransformer.class);%0A%0A    public static void toJson(Stream%3CPartition%3E partitions, CFMetaData metadata, OutputStream out) throws IOException %7B%0A        GsonBuilder gsonBuilder = new GsonBuilder();%0A        gsonBuilder.registerTypeAdapter(RowSerializer.class, new RowSerializer(metadata));%0A        gsonBuilder.registerTypeAdapter(TombstoneSerializer.class, new TombstoneSerializer(metadata));%0A        Gson gson = gsonBuilder.create();%0A%0A        try(JsonWriter writer = new JsonWriter(new OutputStreamWriter(out, %22UTF-8%22))) %7B%0A            writer.setIndent(%22  %22);%0A            writer.beginArray();%0A            partitions.forEach((partition) -%3E %7B%0A                String key = metadata.getKeyValidator().getString(partition.getKey().getKey());%0A                try %7B%0A                    /* TODO: Parse the individual key parts.%0A                    List%3CAbstractType%3C?%3E%3E keyParts = metadata.getKeyValidator().getComponents();%0A                    List%3CColumnDefinition%3E partitionColumns = metadata.partitionKeyColumns();%0A                    assert keyParts.size() == partitionColumns.size();%0A                    writer.name(%22partition_key%22);%0A                    writer.beginObject();%0A                    for(int i = 0; i %3C keyParts.size(); i++) %7B%0A                        ColumnDefinition column = partitionColumns.get(i);%0A                        AbstractType%3C?%3E type = keyParts.get(i);%0A                        writer.name(%22name%22);%0A                        writer.value(column.name.toCQLString());%0A                        writer.name(%22value%22);%0A                        writer.value(type.getString());%0A                    %7D%0A                    writer.endObject();%0A                    */%0A%0A                    writer.beginObject();%0A%0A                    writer.name(%22key%22);%0A                    writer.value(key);%0A%0A                    if(!partition.isLive()) %7B%0A                        writer.beginObject();%0A                        writer.name(%22deletion_time%22);%0A                        writer.value(partition.markedForDeleteAt());%0A                        writer.name(%22tstamp%22);%0A                        writer.value(partition.localDeletionTime());%0A                        writer.endObject();%0A                    %7D%0A%0A                    if (!partition.staticRow().isEmpty()) %7B%0A                        gson.toJson(partition.staticRow(), Row.class, writer);%0A                    %7D%0A%0A                    partition.rows().forEach(unfiltered -%3E %7B%0A                        if (unfiltered instanceof Row) %7B%0A                            gson.toJson(unfiltered, Row.class, writer);%0A                        %7D else %7B%0A                            gson.toJson(unfiltered, RangeTombstoneMarker.class, writer);%0A                        %7D%0A                    %7D);%0A%0A                    writer.endObject();%0A                %7D catch (IOException e) %7B%0A                    logger.error(%22Fatal error parsing partition: %7B%7D%22, key, e);%0A                %7D%0A            %7D);%0A            writer.endArray();%0A        %7D%0A    %7D%0A%7D%0A

Add json transformer.