Handling JSON in android
<p>Hi am new to JSON and I will like to retrieve the values for the json below</p>

<pre><code>{"error":"0","uid":"160","langId":"2","rank":"1"}
</code></pre>

<p>I wrote a JSONParser class, but the main activity class has got me stuck. Below is the code</p>

<pre><code>private static final String LOGTAG = "MyActivity";
    private static String JSONurl = "http://www.afroklore.org/mobile/boot.php?actn=post_prov&amp;lang=1&amp;uid=2&amp;prov=";
    private static final String ERROR = "error";
    private static final String UID = "uid";
    private static final String LANGID = "langId";
    private static final String RANK = "rank";
    JSONArray output = null;
    String id, error, langId, rank;

if (MenuActivity.status == 2) {
            JSONParser jParser = new JSONParser();
            JSONObject json = jParser.getJSONFromUrl(JSONurl);

            try {
                output = json.getJSONArray(ERROR);

                for (int i = 0; i &lt; output.length(); i++) {
                    JSONObject c = output.getJSONObject(i);

                    // Storing each json item in variable
                    id = c.getString(UID);
                    error = c.getString(ERROR);
                    langId = c.getString(LANGID);
                    rank = c.getString(RANK);
                    // creating new HashMap
                    /*
                    HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();

                    // adding each child node to HashMap key =&gt; value
                    map.put(ERROR, error);
                    map.put(UID, id);
                    map.put(LANGID, langId);
                    map.put(RANK, rank);

                    // adding HashList to ArrayList
                    outputField.add(map);*/
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }

        }
        return result;

protected void onPostExecute(String r) {
            // TODO Auto-generated method stub
            super.onPostExecute(result);
            String msg = "Login successful";

            if (MenuActivity.status == 2) {
                Log.d(LOGTAG, result);
                // Log.d(LOGTAG, outputField.get(ERROR));
                Log.d(LOGTAG, error + " " + id + " " + langId + " " + rank);
</code></pre>

<p>}</p>
