Skip to content

Instantly share code, notes, and snippets.

@jpzhu
Created September 4, 2013 08:51
Show Gist options
  • Save jpzhu/6434441 to your computer and use it in GitHub Desktop.
Save jpzhu/6434441 to your computer and use it in GitHub Desktop.
json android java
JSONArray response_out = null;
static JSONObject jObj = null;
private static final String API_REQUEST_CODE = "r";
private static final String API_SERVICE_CODE = "s";
private static final String API_RESPONSE_OUT = "o";
private static final String TAG_ID = "id";
private static final String TAG_CATEGORY = "category";
private static final String TAG_NAME = "name";
private static final String TAG_STREAM = "stream";
private static final String TAG_IMAGE = "image";
....................
jObj = new JSONObject(response.toString());
response_out = jObj.getJSONArray(API_RESPONSE_OUT);
for(int i = 0; i < response_out.length(); i++){
JSONObject c = response_out.getJSONObject(i);
// Storing each json item in variable
String id = c.getString(TAG_ID);
String name = c.getString(TAG_NAME);
String category = c.getString(TAG_CATEGORY);
String stream = c.getString(TAG_STREAM);
String image = c.getString(TAG_IMAGE);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment