try {
JSONObject jsonObject = (JSONObject) new JSONParser().parse(data);
for (Object c : (JSONArray) jsonObject.get("objects")){
jsonObject = (JSONObject) c;
total_count = total_count + (long) jsonObject.get("count");
Stats stats = new Stats(Integer.parseInt((String)jsonObject.get("id")),(String) jsonObject.get("name"),(long) jsonObject.get("count"));
stats_array.add(stats);
}
} catch (ParseException ex) {
Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
}
}
this.print.getjTextArea1().setText(this.print.getjTextArea1().getText() + "\n\n" +"************STATISTICS FOR BOOKS *******************" + "\n\n");
//get percentage
for (int i=0; i<stats_array.size();i++){
Stats aux= (Stats) stats_array.get(i);
aux.setPercen(aux.getPercentage((float)100, aux.getCount(), total_count));
this.print.getjTextArea1().setText(this.print.getjTextArea1().getText() + aux.getProduct_url() +" : " + aux.getPercen() + " % " +"\n");
}
}