title: Create json object using json.simple
body: <p>I am using the following libraries to create some JSON object.</p>
  
  <pre><code>import org.json.simple.JSONArray;
  import org.json.simple.JSONObject;
  </code></pre>
  
  <p>The json I am trying to create is this:</p>
  
  <pre><code>{
      "function": "create_contact_group",
      "parameters": [{
          "user_id": "teer",
          "comp_id": "97",
          "contact_group_name": "Test01",
          "invite_user_list": [{
              "invite_user_id": "steve"
          }]
  
      }]
  }
  </code></pre>
  
  <p>My function looks like this:</p>
  
  <pre><code>public JSONObject createJSONRequest() {
      /* Create json object */
      JSONObject jsonObject = new JSONObject();
  
      Map&lt;String, String&gt; map = new HashMap&lt;&gt;();
      map.put("user_id", "teer");
      map.put("comp_id", "97");
      map.put("contact_group_name", "Test01");
  
      List&lt;String&gt; mInviteUserList = new ArrayList&lt;&gt;();
      mInviteUserList.add("steve");
  
      /* Create the list of invitee */
      Map&lt;String, String&gt; inviteList = new HashMap&lt;&gt;();
      for(String user : mInviteUserList) {
          inviteList.put("invite_user_id", user);
      }
      /* Add the invitees into the json array */
      JSONArray inviteArray = new JSONArray();
      inviteArray.add(inviteList);
      /* Add the json array to the json object */
      jsonObject.put("invite_user_list", inviteArray);
  
      JSONArray parameterlist = new JSONArray();
      parameterlist.add(map);
      parameterlist.add(jsonObject);
  
      jsonObject.put("parameters", parameterlist);
      jsonObject.put("function", "create_contact_group");
  
      Log.d(TAG, "jsonObject: " + jsonObject.toJSONString());
  
      return jsonObject;
  }
  </code></pre>
  
  <p>However, the function crashes when I get to the following line:</p>
  
  <pre><code>Log.d(TAG, "jsonObject: " + jsonObject.toJSONString())
  </code></pre>
  
  <p>I think it has something to do with this line here:</p>
  
  <pre><code>parameterlist.add(jsonObject);
  </code></pre>
  
  <p>Stacktrace:</p>
  
  <p>java.lang.StackOverflowError                                                                       java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:95)                                                                       at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:132)
  at java.lang.StringBuffer.append(StringBuffer.java:126)                                                                             at org.json.simple.JSONValue.escape(JSONValue.java:266)                                                                          at org.json.simple.JSONObject.toJSONString(JSONObject.java:116)</p>
  
  <p>Many thanks for any suggestions,</p>