title: How to add two JSON formatted Java Strings together?
body: <p>I have two JSON Format Strings </p>
  
  <pre><code> {"user1":{"Iden":4,"nID":1},"user2":{"Iden":5,"nID":1}} // String A JSON 
  
   {"user1":{"Iden":4,"nID":1},"user3":{"Iden":6,"nID":1},"user2":{"Iden":5,"nID":1}}  
  </code></pre>
  
  <p>In the below program these above JSON are formatted by Eclipse IDE </p>
  
  <p>This is my program:</p>
  
  <pre><code>import java.util.Map;
  
  import org.codehaus.jackson.type.TypeReference;
  
  import com.tradeking.at.util.JsonHelper;
  
  public class Hi {
      private static JsonHelper jsonHelper = JsonHelper.getInstance();
  
      public static void main(String[] args) throws Exception {
  
          Map&lt;String, Tracker&gt; totalCusts = null;
  
          String A = "{\"user1\":{\"Iden\":4,\"nID\":1},\"user2\":{\"Iden\":5,\"nID\":1}}";
          String B = "{\"user1\":{\"Iden\":4,\"nID\":1},\"user3\":{\"Iden\":6,\"nID\":1},\"user2\":{\"Iden\":5,\"nID\":1}}";
  
          String totalString =  A+B;
  
          if (null != totalString) {
              totalCusts = (Map&lt;String, Tracker&gt;) jsonHelper.toObject(
                      totalString, new TypeReference&lt;Map&lt;String, Tracker&gt;&gt;() {
                      });
  
          }
  
          System.out.println(totalCusts);
  
      }
  
  }
  </code></pre>
  
  <p>Tracker.java:</p>
  
  <pre><code>import org.json.JSONObject;
  
  public class Tracker extends JSONObject{
  
  }
  </code></pre>
  
  <p>When i ran the above , the Output is</p>
  
  <pre><code>{user1={}, user2={}}
  </code></pre>
  
  <p>if I use this:</p>
  
  <pre><code>String totalString =  B + A ;
  </code></pre>
  
  <p>The O/p is:</p>
  
  <pre><code>{user1={}, user3={}, user2={}}
  </code></pre>
  
  <p>Please let me know how I can add two JSON Strings??</p>