Android convert JSONObject to HashMap and display in ListView with SimpleAdapter
<p>I try to search converting <code>JSONObject</code> to <code>HashMap</code> but most of the results are for Java not Android. Hence, I hope someone can share if you have experience in doing this before.</p>

<p><strong>listview_with_simpleAdapter_and_hashmap.java</strong></p>

<pre><code>@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main4);
    String[] food_id= new String[]{"1", "2", "3"};
    String[] food_name = new String[]{"apple", "orange", "banana"};
    List&lt;HashMap&lt;String, String&gt;&gt; aList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();

    for (int i = 0; i &lt; 3; i++) {
        HashMap&lt;String, String&gt; hm = new HashMap&lt;String, String&gt;();
        hm.put("ID", food_id[i]);
        hm.put("Name", food_name[i]);
        aList.add(hm);
    }

    String[] from = {"ID", "Name"};
    int[] to = {R.id.text_id, R.id.text_name};
    SimpleAdapter adapter = new SimpleAdapter(this, aList, R.layout.list_item, from, to);
    ListView listView = (ListView) findViewById(R.id.listView);
    listView.setAdapter(adapter);

}
</code></pre>

<p><strong>this file is working fine and simply display 2 columns in each row;</strong> </p>

<p><a href="https://i.stack.imgur.com/ilvz7.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ilvz7.jpg" alt="enter image description here"></a></p>

<p><strong>json.java</strong></p>

<pre><code>TextView mTxtDisplay;
String url = "http://192.168.1.103/web_service/omg.php/";

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mTxtDisplay = (TextView) findViewById(R.id.tv);

    JsonObjectRequest jsObjRequest = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener&lt;JSONObject&gt;() {

        @Override
        public void onResponse(JSONObject response) {
            mTxtDisplay.setText(response.toString());
        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
            // TODO Auto-generated method stub
        }
    });
    RequestQueue requestQueue = Volley.newRequestQueue(this);
    requestQueue.add(jsObjRequest);
</code></pre>

<p><strong>192.168.1.103/web_service/omg.php/</strong></p>

<pre><code>{
"32":"Western Food",
"35":"Japanese Food",
"37":"Italian Food"
}
</code></pre>

<p>JSON is working fine as well. The format is exactly the same as the <code>ListView</code> data -> ID and Name. </p>

<p>So my question is how to convert the <code>JSONObject</code> in <em>omg.php</em> to listview_with_simpleAdapter_and_hashmap.java ? I just need a simple example.</p>