Parse Bill n Pay Customer Info Json Response
//{}&&{"biller":{"customerinfo":{"customer":[{"firstname":"S","middlename":"R","lastname":"S","internalid":"502CD927-651E-E67C-A3FD-AABEC48F026B","id":"502CD927-651E-E67C-A3FD-AABEC48F026B"}]}}}
JSONParser parser = new JSONParser();
//cut out first 4 characters {}&&
jsonString = jsonString.substring(4);
Object obj = parser.parse(jsonString);
JSONObject jsonObject = (JSONObject) obj;
JSONObject biller = (JSONObject) jsonObject.get("biller");
JSONObject customerinfo = (JSONObject) biller.get("customerinfo");
JSONArray customerArray = (JSONArray) customerinfo.get("customer");
JSONObject customer = (JSONObject) customerArray.get(0);
System.out.println("fullname: "+customer.get("firstname")+" "+customer.get("lastname"));
System.out.println("customeremail: "+customer.get("email").toString());
JSONParser parser = new JSONParser();
//cut out first 4 characters {}&&
jsonString = jsonString.substring(4);
Object obj = parser.parse(jsonString);
JSONObject jsonObject = (JSONObject) obj;
JSONObject biller = (JSONObject) jsonObject.get("biller");
JSONObject customerinfo = (JSONObject) biller.get("customerinfo");
JSONArray customerArray = (JSONArray) customerinfo.get("customer");
JSONObject customer = (JSONObject) customerArray.get(0);
System.out.println("fullname: "+customer.get("firstname")+" "+customer.get("lastname"));
System.out.println("customeremail: "+customer.get("email").toString());
Comments
Post a Comment