Skip to content

Instantly share code, notes, and snippets.

@frhd
Created February 18, 2014 14:10
Show Gist options
  • Save frhd/9071688 to your computer and use it in GitHub Desktop.
Save frhd/9071688 to your computer and use it in GitHub Desktop.
Parsing JSON in Java
JSONObject obj = new JSONObject("{interests : [{interestKey:Dogs}, {interestKey:Cats}]}");
List<String> list = new ArrayList<String>();
JSONArray array = obj.getJSONArray("interests");
for(int i = 0 ; i < array.length() ; i++){
list.add(array.getJSONObject(i).getString("interestKey"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment