title: Capitalized fields with POJO Input Handlers for Java AWS Lambda
body: <p>According to the documentation described here: <a href="http://docs.aws.amazon.com/lambda/latest/dg/java-programming-model-req-resp.html" rel="nofollow noreferrer">http://docs.aws.amazon.com/lambda/latest/dg/java-programming-model-req-resp.html</a> one can create its own POJO to serialise input and output for Java AWS Lambda.</p>
  <p>However it appears that it doesn't properly work for input requests where fields are capitalised. For instance, the format of input for a custom resource lambda looks like:</p>
  <pre><code>{&quot;RequestType&quot;:&quot;Create&quot;, 
  &quot;ServiceToken&quot;:&quot;arn:aws:lambda:....&quot;, 
  &quot;ResponseURL&quot;:&quot;https://cloudformation-custom-resource-response-e...&quot;,
  ...}
  </code></pre>
  <p>This can be easily tested via this simple MCVE code:</p>
  <pre><code>package test;
  
  import com.amazonaws.services.lambda.runtime.Context;
  import com.amazonaws.services.lambda.runtime.RequestHandler;
  import org.apache.logging.log4j.LogManager;
  import org.apache.logging.log4j.Logger;
  
  public class TestLambda implements RequestHandler&lt;TestLambda.TestEvent, String&gt; {
  
      private static final Logger logger = LogManager.getLogger(TestLambda.class);
  
      @Override
      public String handleRequest(TestEvent event, Context context) {
           logger.debug(event.toString());    
           return null;
      }
  
      public static final class TestEvent {
          private String key1;
  
          private String Key2;
  
          private String key3;
  
          public String getKey1() {
              return key1;
          }
  
          public void setKey1(String key1) {
              this.key1 = key1;
          }
  
          public String getKey2() {
              return Key2;
          }
  
          public void setKey2(String key2) {
              Key2 = key2;
          }
  
          public String getKey3() {
              return key3;
          }
  
          public void setKey3(String key3) {
              this.key3 = key3;
          }
  
          @Override
          public String toString() {
              return &quot;TestEvent{&quot; +
                      &quot;key1='&quot; + key1 + '\'' +
                      &quot;, Key2='&quot; + Key2 + '\'' +
                      &quot;, key3='&quot; + key3 + '\'' +
                      '}';
          }
      }
  }
  </code></pre>
  <p>Then create a test in AWS Console for this lambda and pass there as a request the following json:</p>
  <pre><code>{
    &quot;key3&quot;: &quot;value3&quot;,
    &quot;Key2&quot;: &quot;value2&quot;,
    &quot;Key1&quot;: &quot;value1&quot;
  }
  </code></pre>
  <p>The result in logs will be:</p>
  <pre><code>2017-11-06 09:30:13 16849696-c2d5-11e7-80c3-150a37863c42 DEBUG TestLambda:15 - TestEvent{key1='null', Key2='null', key3='value3'}
  </code></pre>
  <p>Is there any way to deserialise this input without dealing with a raw byte stream as they suggest in that topic?</p>
  <blockquote>
  <p>You shouldn't rely on any other features of serialization frameworks
  such as annotations. If you need to customize the serialization
  behavior, you can use the raw byte stream to use your own
  serialization.</p>
  </blockquote>
  <p>This seems to me to be a great limitation of Java AWS Lambdas if we can not freely create a POJO for any type of event.</p>