Page 123 - 3-2
P. 123
protected String doInBackground(String... args) {
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
// getting JSON string from URL
JSONObject json = jParser.makeHttpRequest(url_all_products, "GET", params);
// Check your log cat for JSON reponse
Log.d("All Products: ", json.toString());
try {
// Checking for SUCCESS TAG
int success = json.getInt(TAG_SUCCESS);
Log.d(" 여긴가", "7.3333333_allproducts");
if (success == 1) {
// products found
// Getting Array of Products
products = json.getJSONArray(TAG_PRODUCTS);
// looping through All Products
for (int i = 0; i < products.length(); i++) {
JSONObject c = products.getJSONObject(i);
// Storing each json item in variable
String code = c.getString(TAG_CODE);
String name = c.getString(TAG_NAME);
String num ="1";
String price = c.getString(TAG_PRICE);
sum_price+=Integer.valueOf(price).intValue();
Log.d(" 여긴가_delete", code);
// creating new HashMap
HashMap<String, String> map = new HashMap<String, String>();
// adding each child node to HashMap key => value
map.put(TAG_CODE, code);
map.put(TAG_NAME, name);
map.put(TAG_NUM, num);
map.put(TAG_PRICE, price);
// adding HashList to ArrayList
productsList.add(map);
Log.d(" 여긴가", "7.3_allproducts");
- 123 -