parsing url in json format
<p>I am developing an android application in which i have to parse data from url in json format.I HAVE TRIED THE CODE.I have parsed the url like as follows </p>

<pre><code>private JSONObject jObject;
    private String jString = "{\"menu\": {\"id\": \"file\", \"value\": \"File\", \"popup\": { \"menuitem\": [ {\"value\": \"New\",   \"onclick\": \"CreateNewDoc()\"}, {\"value\": \"Open\", \"onclick\": \"OpenDoc()\"}, {\"value\": \"Close\", \"onclick\": \"CloseDoc()\"}]}}}";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        try {
            parse();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    private void parse() throws Exception {
        jObject = new JSONObject(jString);

        JSONObject menuObject = jObject.getJSONObject("menu");
        String attributeId = menuObject.getString("id");
        System.out.println(attributeId);

        String attributeValue = menuObject.getString("value");
        System.out.println(attributeValue);

        JSONObject popupObject = menuObject.getJSONObject("popup");
        JSONArray menuitemArray = popupObject.getJSONArray("menuitem");

        for (int i = 0; i &lt; 3; i++) {
            System.out.println(menuitemArray.getJSONObject(i)
                    .getString("value").toString());
            System.out.println(menuitemArray.getJSONObject(i).getString(
                    "onclick").toString());
        }
    }
</code></pre>

<p>But running the code does not give me the result..
If anyone has done it before.Can he help me</p>

<p>Thanks in advance
tushar</p>
