title: Gson serialize with two List types in a single JSON object
body: <p>I have two types of list to bind the request using Gson library. I tried in a way, it is working as excepted. But I want to know whether we have any default procedure to serialize the lists.</p>
  
  <p>I tried below and working. But this is not the way to implement. Searching for better solution.</p>
  
  <pre><code>class Request{
      @Expose
      @SerializedName("ListC")
      private List&lt;TypeOne&gt; mList;
  
      public Request(List&lt;TypeOne&gt; listOne, List&lt;TypeTwo&gt; listTwo){
          this.mList = new ArrayList&lt;&gt;();
          for (int i = 0; i &lt; listTwo.size(); i++) {
             // Adding the Typetwo values in TypeOne model class - Not best approach
             listOne.get(i).setAmount(listTwo.get(i).getAmount());
             listOne.get(i).setName(listTwo.get(i).getName());
             listOne.get(i).setType(listTwo.get(i).getType());
          }
          this.mList.addAll(listOne);
      }
  
      public String getJsonString(){
           Gson gson = new GsonBuilder()
              .registerTypeAdapter(TypeOne.class, new Serializer())
              .registerTypeAdapter(Date.class, new DateSerializer())
              .excludeFieldsWithoutExposeAnnotation()
              .create();
  
      JsonObject in = new JsonObject();
      in.add("in", gson.toJsonTree(this));
  
      JsonObject obj = new JsonObject();
      obj.add("req", in);
  
      return obj.toString();
      }
  }
  </code></pre>
  
  <p>Is anyone faced the similar issue and fixed this, please direct me to get it done. Trying from long back to find better solution.</p>
  
  <p>Output JSON:</p>
  
  <pre><code>{
  "list":[
      Obj{
      "Type_1_object_1":"value",
      "Type_1_object_2":"value",
      "Type_1_object_3":"value",
      "Type_2_object_5":"value",
      "Type_2_object_6":"value"
      },
      Obj{
      "Type_1_object_1":"value",
      "Type_1_object_2":"value",
      "Type_1_object_3":"value", 
      "Type_2_object_5":"value", 
      "Type_2_object_6":"value"
      }
  ]
  }
  </code></pre>