title: AWS lambda java response does not support nested objects?
body: <p>I'm new to Java so this may not be related to AWS lambda at all.  However, lambda takes such liberties with input/output objects that I'm assuming it's the culprit here.</p>
  
  <p>I'm building my first lambda function and want to return a simple JSON structure (simplified further for this example):</p>
  
  <pre><code>{
    "document" : "1",
    "person" : { "name" : "John Doe" }
  }
  </code></pre>
  
  <p>However, when lambda serializes the JSON it always sets "person" to a blank object!</p>
  
  <pre><code>{
    "document": "1",
    "person": {}
  }
  </code></pre>
  
  <p>Here is my code in full:</p>
  
  <pre><code> - test1.java
  package handler_test;
  import com.amazonaws.services.lambda.runtime.Context;
  import com.amazonaws.services.lambda.runtime.RequestHandler;
  public class test1 implements RequestHandler&lt;String, ResponseClass&gt; {
      @Override
      public ResponseClass handleRequest(String input, Context context) {
        return new ResponseClass();
      }
  }
  
   - ResponseClass.java
  package handler_test;
  import org.json.JSONException;
  import org.json.JSONObject;
  public class ResponseClass {
      String document;
      JSONObject person;
  
      public String getdocument() {
          return "1";
      }
  
      public JSONObject getperson() {
          try {
              return new JSONObject("{ \"name\" : \"John Doe\" }");
          } catch (JSONException e1) {
              System.out.println("error creating jsonobject");
              return null;
          }
      }
  
      public ResponseClass() {
      }
  }
  </code></pre>
  
  <p>I've tried this with dozens of variations, using objects instead of JSONObjects, converting getperson output to a string (which works, if I wanted a string), etc. If I store the values and print them to the logger, it's fine.  But as soon as I try to return it through lambda it goes pear-shaped.  I've combed the 'net and can't find anything more on AWS-lambda java response objects beyond Amazon's "greetings" sample code, which just includes two strings.  Any suggestions greatly appreciated!</p>