Android convert JSONObject to HashMap and display in ListView with SimpleAdapter

前端 未结 2 1042
没有蜡笔的小新
没有蜡笔的小新 2021-01-24 04:05

I try to search converting JSONObject to HashMap but most of the results are for Java not Android. Hence, I hope someone can share if you have experien

2条回答
  •  盖世英雄少女心
    2021-01-24 04:38

    try this code to convert Jsonobject to hashmap

     Map params = new HashMap();
                    try
                    {
    
                       Iterator keys = jsonObject.keys();
    
                        while (keys.hasNext())
                        {
                            String key = (String) keys.next();
                            String value = jsonObject.getString(key);
                            params.put(key, value);
    
                        }
    
    
                    }
                    catch (Exception xx)
                    {
                        xx.toString();
                    }
    

提交回复
热议问题