title: How to Traverse in the nested JSON data using java
body: <p>I'm trying to get the values of <code>Alpha</code>, <code>Beta</code> and <code>Gamma</code> from a nested JSON data file.</p>
  
  <p>I'm trying get the <code>Alpha</code> value using something like this</p>
  
  <pre><code>Object o = new JSONParser().parse(new FileReader(newFile("C:\\Users\\abc\\Documents\\file.json")));
  JSONObject jo = (JSONObject) o;
  
  JSONArray resultCode = (JSONArray) jo.get("mkDetails");
  
  JSONObject x = (JSONObject) resultCode.get(0);
  x.get("Alpha").toString()       
  </code></pre>
  
  <p>This is the JSON:</p>
  
  <pre><code>{
    "metadata": {
      "offset": 0,
      "psize": 10
    },
    "svc": [
      {
        "mNumber": "225",
        "markIp": {
          "Name": "Ant",
          "eDate": "3006-08-01",
          "cDate": "9999-12-31"
        },
        "mkDetails": [
          {
            "Alpha": "D",
            "Beta": "S"
          }
        ],
        "mNetDetails": [
          {
            "Gaama": "213",
            "mkTypeCode": "23"
          }
        ]
      }
    ],
    "serviceFault": {
      "faultType": null,
      "faultCode": null,
      "message": null
    }
  }
  </code></pre>