package com.perpustakaan; import java.util.ArrayList; import java.util.List; import org.apache.http.NameValuePair; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.util.Log; public class JSONreader implements Runnable { // Creating JSON Parser object JSONParser jParser = new JSONParser(); //ArrayList> pasienList; // url to get all pasien list // JSON Node names private static final String TAG_SUCCESS = "success"; private static final String TAG_PASIEN = "pasien"; private static final String TAG_JAM = "jam"; private static final String TAG_NOMOR = "nomor"; private static final String TAG_OBAT = "obat"; JSONreader(){ try{ }catch(Exception ex){ Log.i("HttpData","URL Malformatted"); } } void setAntrian(String ttgl){ // pasien JSONArray JSONArray pasien = null; // Building Parameters List params = new ArrayList(); // getting JSON string from URL JSONObject json = jParser.makeHttpRequest("http://192.168.0.10/index.php", "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); if (success == 1) { // pasien found // Getting Array of Products pasien = json.getJSONArray(TAG_PASIEN); // looping through All Products for (int i = 0; i < pasien.length(); i++) { JSONObject c = pasien.getJSONObject(i); // Storing each json item in variable String jam = c.getString(TAG_JAM); String nomor = c.getString(TAG_NOMOR); String sobat = c.getString(TAG_OBAT); boolean obat = (sobat.equalsIgnoreCase("true"))?true:false; } } else { // no pasien found // Launch Add New product Activity Log.i("JSON : ","no pasien found"); } } catch (JSONException e) { e.printStackTrace(); } } @Override public void run() { // TODO Auto-generated method stub } }