title: Jackson encode all properties to base64
body: <p>I have more than one class that I want to serialize using <strong>Jackson</strong> to generate Json, for example</p>
  
  <pre><code>public class A{
    int id;
    String name;
    Object database;
    ... getter and setter
  }
  </code></pre>
  
  <p>I need to encode all value of the json to base64, so I configure the object mapper like this</p>
  
  <pre><code>public class Base64Serializer&lt;T&gt; extends StdSerializer&lt;T&gt; {
  
      private static final long serialVersionUID = 1L;
  
      protected Base64Serializer(Class&lt;?&gt; t, boolean f) {
          super(t, f);
      }
  
      @Override
      public void serialize(T value, JsonGenerator jsonGenerator, SerializerProvider arg2) throws IOException {
          String ecnodedOutput = Base64.getEncoder().encodeToString(((String) value).getBytes());
          jsonGenerator.writeString(ecnodedOutput);
      }
  }
  
  //Using the base64 Serializer to configure Object mapper 
      SimpleModule module = new SimpleModule();
      module.addSerializer(new Base64Serializer(String.class, false));
      objectMapper.registerModule(module);
      objectMapper.writerWithDefaultPrettyPrinter().writeValue(outputStream,intanceOfClassA);
  </code></pre>
  
  <p>The problem is it's only encode the String type as the serializer only accept one type, is there any method to encode all field values, (long, int, object, etc..) I mean to encode all value of the json field regarding it type of string or int??</p>