title: Own Firebase deserializer
body: <p>I have old legacy code that I don't want to rewrite and I'm using gson and io.gsonfire to do mapping with special json to my java class. I want to just transform Datasnapshot to json string so I can use my other implementation. I will not be able to use Datasnapshot.getValue(SomeClass.class) because my transformer is special.</p>
  
  <pre><code>public class BlockTypeSelector {
  
  public Gson createGson(){
  
      GsonFireBuilder builder = new GsonFireBuilder()
      .registerTypeSelector(AbstractPhrase.class, new TypeSelector&lt;AbstractPhrase&gt;() {
          @Override
          public Class&lt;? extends AbstractPhrase&gt; getClassForElement( JsonElement readElement) {
               JsonElement element = readElement.getAsJsonObject().get("dotted");
               if( element != null ){
                    return DottedFillPhrase.class;
               }
  
              return Phrase.class;
          }
  
      })
      .registerTypeSelector(AbstractParagraph.class, new TypeSelector&lt;AbstractParagraph&gt;() {
          @Override
          public Class&lt;? extends AbstractParagraph&gt; getClassForElement( JsonElement readElement) {
               JsonElement element = readElement.getAsJsonObject().get("cells");
               if( element != null ){
                    return TableParagraph.class;
               }
  
               element = readElement.getAsJsonObject().get("padding");
               if( element != null ){
                  return TableCell.class;
               }
  
               element = readElement.getAsJsonObject().get("fill");
               if( element != null ){
                  return FillParagraph.class;
               }
  
              return Paragraph.class;
          }
  
      })
      .registerTypeSelector(BaseElement.class, new TypeSelector&lt;BaseElement&gt;() {
          @Override
          public Class&lt;? extends BaseElement&gt; getClassForElement(JsonElement readElement) {
              JsonElement element = readElement.getAsJsonObject().get("type");
              if( element == null ){
                  throw new JsonSyntaxException( "You must have a type in block" );
              }
              String kind = element.getAsString();
              if(kind.equals("LINE")){
                  return Line.class;
              }else if(kind.equals("BLOCK")) {
                  return Block.class; 
              }else if(kind.equals("IMAGE")) {
                  return Image.class; 
              }else if(kind.equals("QR")) {
                  return QRCode.class; 
              }else if(kind.equals("BARCODE")) {
                  return Barcode.class; 
              } else {
                  return null; //returning null will trigger Gson's default behavior
              }
          }
      });
  
      return builder.createGson();
  
  
  }
  
  }
  </code></pre>
  
  <p>So any pointers on how to make something like this </p>
  
  <pre><code>{ key = 787878, value = {document={pages={0={blocks={0={position={3=60.1, 2=50, 1=28.95, 0=25.6}, useAscender=true, type=BLOCK, border={thickness=0.1}}}}}, name=22323}} }
  </code></pre>
  
  <p>To json String? My worries is the 3:60 and that stuff. How can I know that it is an array and not "3" : "60" json?</p>