Skip to content

Instantly share code, notes, and snippets.

@amirul12
Created March 11, 2019 04:34
Show Gist options
  • Select an option

  • Save amirul12/f66dd8a689322233fd3ba7e813b2fc69 to your computer and use it in GitHub Desktop.

Select an option

Save amirul12/f66dd8a689322233fd3ba7e813b2fc69 to your computer and use it in GitHub Desktop.
String s = "{menu:{\"1\":\"sql\", \"2\":\"android\", \"3\":\"mvc\"}}";
JSONObject jObject = new JSONObject(s);
JSONObject menu = jObject.getJSONObject("menu");
Map<String,String> map = new HashMap<String,String>();
Iterator iter = menu.keys();
while(iter.hasNext()){
String key = (String)iter.next();
String value = menu.getString(key);
map.put(key,value);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment