title: how to create a nested json in java
body: <p>I am having a problem in making a json in java. below is the JSON which I have to create through java code. </p>
  
  <pre><code>{"status":"0",
  "Response":{ 
      "abc":[
          "def":[
              "fgh":[
                  {
                      "abc":"abc",
                      "def":"abc",
                      "ghi":"abc",
  
                  },
                  {
                      "abc":"abc",
                      "def":"abc",
                      "ghi":"abc",
  
                  },
                  {
                      "abc":"abc",
                      "def":"abc",
                      "ghi":"abc",
  
                  }
                    ],
              "ghi":[
                  {
                      "abc":"abc",
                      "def":"abc",
                      "ghi":"abc",
  
                  },
                  {
                      "abc":"abc",
                      "def":"abc",
                      "ghi":"abc",
  
                  },
                  {
                      "abc":"abc",
                      "def":"abc",
                      "ghi":"abc",
  
                  }
                     ]
               ]
         ]
       ]
  }
  }   
  </code></pre>
  
  <p>and here is the java code.</p>
  
  <pre><code>    JSONObject result = new JSONObject();
      JSONObject abcObject = new JSONObject();
      JSONArray resultArray = new JSONArray();
      JSONArray fghArray = new JSONArray();
      JSONArray defArray = new JSONArray();
      JSONArray abcArray = new JSONArray();
  
  abcObject.put("abc");
  abcObject.put("def");
  abcObject.put("ghi");
  fghArray.add(abcObject);
  defArray.add(fghArray);
  abcArray.add(defArray);
  result.put("status", 0);
  result.put("Response",abcArray); 
  return resultJson.toString();
  </code></pre>
  
  <p>The Problem:</p>
  
  <p>when i send back the json to a jsp. the output is not showing up.</p>
  
  <pre><code>success:function(data) {
              alert(data);
             var json = $.toJSON(data); 
             alert(json);
          },
  </code></pre>
  
  <p>alert(data) is alerting an object and 2nd alert alert(json) is not showing anything.</p>