I have a HashMap as follows:
Map<String, String> myMap = new HashMap<String,String>();
myMap.put("apple","mac");
JSONArray listOfEntities = new JSONArray();
listOfEntities.put(myMap);
Question:
from listOfEntities I need to get “apple”. How to do it? Thanks for your help.
As you’re storing key/value pair, you shouldn’t use a JSONArray, which only contains indexed values, but JSONObject, which is the JSON structure to store K/V pairs
so