an easy way could be
- parse a JSON string using GSON
like this:
String json = "{\"GetReportResult\":" + " [" + " {\"bulan\":\"4\",\"total\":\"2448\",\"type\":\"CHEESE1K\"}, " + " {\"bulan\":\"4\",\"total\":\"572476\",\"type\":\"ESL\"}," + " {\"bulan\":\"4\",\"total\":\"46008\",\"type\":\"ESL500ML\"}," + " {\"bulan\":\"5\",\"total\":\"5703\",\"type\":\"CHEESE1K\"}," + " {\"bulan\":\"5\",\"total\":\"648663\",\"type\":\"ESL\"}," + " {\"bulan\":\"5\",\"total\":\"51958\",\"type\":\"WHP\"}," + " {\"bulan\":\"6\",\"total\":\"6190\",\"type\":\"CHEESE1K\"}," + " {\"bulan\":\"6\",\"total\":\"443335\",\"type\":\"ESL\"}," + " {\"bulan\":\"6\",\"total\":\"30550\",\"type\":\"ESL500ML\"}," + " ]" + "}"; ReportResults reports = new Gson().fromJson(json, ReportResults.class); List<ReportResult> results = reports.getGetReportResult(); for(ReportResult result:results)System.out.println(result);
ReportResults Class:
package com.yourcomp.test; import java.util.List; public class ReportResults { private List<ReportResult> GetReportResult; public List<ReportResult> getGetReportResult() { return GetReportResult; } public void setGetReportResult(List<ReportResult> getReportResult) { GetReportResult = getReportResult; } }
ReportResult Class:
package com.yourcomp.test; public class ReportResult { private String bulan; private String total; private String type; public String getBulan() { return bulan; } public void setBulan(String bulan) { this.bulan = bulan; } public String getTotal() { return total; } public void setTotal(String total) { this.total = total; } public String getType() { return type; } public void setType(String type) { this.type = type; } @Override public String toString() { return "ReportResult [bulan=" + bulan + ", total=" + total + ", type=" + type + "]"; } }
Then use the analyzed result, which will be shown in TableLayout.
source share