Created
September 4, 2013 08:51
-
-
Save jpzhu/6434441 to your computer and use it in GitHub Desktop.
json android java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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