List of usage examples for org.json.simple JSONValue toJSONString
public static String toJSONString(Object value)
From source file:org.openmrs.module.accessmonitor.web.controller.AccessMonitorOrderController.java
@RequestMapping(value = "/module/accessmonitor/order", method = RequestMethod.GET) public void person(ModelMap model, HttpServletRequest request) { offset = 0;/* w ww.j a v a 2s .co m*/ // parse them to Date, null is acceptable DateFormat format = new SimpleDateFormat("MM/dd/yyyy"); // Get the from date and to date Date to = null; Date from = null; try { from = format.parse(request.getParameter("datepickerFrom")); } catch (Exception e) { //System.out.println("======From Date Empty======="); } try { to = format.parse(request.getParameter("datepickerTo")); } catch (Exception e) { //System.out.println("======To Date Empty======="); } // get all the records in the date range orderAccessData = ((OrderAccessService) Context.getService(OrderAccessService.class)) .getOrderAccessesByAccessDateOrderByPatientId(from, to); if (orderAccessData == null) { orderAccessData = new ArrayList<OrderServiceAccess>(); } // get date for small graph Date toSmall = to; Date fromSmall = null; Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, 1); if (toSmall == null) { toSmall = calendar.getTime(); } else { calendar.setTime(toSmall); } calendar.add(Calendar.DATE, -DAYNUM); fromSmall = calendar.getTime(); List<String> dateStrings = new ArrayList<String>(); for (int i = 0; i < DAYNUM; i++) { if (i == DAYNUM - 1) { dateStrings.add(format.format(toSmall)); } else if (i == 0) { dateStrings.add(format.format(fromSmall)); } else { dateStrings.add(""); } } ArrayList<ArrayList<Integer>> tooltip = new ArrayList<ArrayList<Integer>>(); tooltip.add(new ArrayList<Integer>()); for (int j = 0; j < SHOWNUM + 1; j++) { tooltip.get(0).add(1000 + j); } for (int i = 1; i < DAYNUM + 1; i++) { tooltip.add(new ArrayList<Integer>()); tooltip.get(i).add(i); for (int j = 0; j < SHOWNUM; j++) { tooltip.get(i).add(0); } } ArrayList<String> patientIds = new ArrayList<String>(); ArrayList<Integer> patientCounts = new ArrayList<Integer>(); for (OrderServiceAccess oa : orderAccessData) { // data for big graph String idString = (oa.getPatientId() == null) ? "No ID" : oa.getPatientId().toString(); int index = patientIds.indexOf(idString); if (index < 0) { if (patientIds.size() >= SHOWNUM) break; patientIds.add(idString); patientCounts.add(1); index = patientIds.size() - 1;//index = personIds.indexOf(idString); } else { patientCounts.set(index, patientCounts.get(index) + 1); } // data for small graph if (oa.getAccessDate().after(fromSmall) && oa.getAccessDate().before(toSmall)) { int index2 = (int) ((oa.getAccessDate().getTime() - fromSmall.getTime()) / (1000 * 60 * 60 * 24)); if (index2 < DAYNUM && index2 >= 0) tooltip.get(index2 + 1).set(index + 1, tooltip.get(index2 + 1).get(index + 1) + 1); } } String patientIdString = JSONValue.toJSONString(patientIds); String patientCountString = JSONValue.toJSONString(patientCounts); String dateSmallString = JSONValue.toJSONString(dateStrings); String tooltipdata = JSONValue.toJSONString(tooltip); model.addAttribute("patientIds", patientIdString); model.addAttribute("patientCounts", patientCountString); model.addAttribute("dateSmallString", dateSmallString); model.addAttribute("tooltipdata", tooltipdata); model.addAttribute("user", Context.getAuthenticatedUser()); //model.addAttribute("tables1", orderAccessData); //model.addAttribute("dateSmall", dateStrings); model.addAttribute("currentoffset", String.valueOf(offset)); }
From source file:org.openmrs.module.accessmonitor.web.controller.AccessMonitorOrderController.java
@RequestMapping(value = "/module/accessmonitor/order", method = RequestMethod.POST) public void postSave(ModelMap model, HttpServletRequest request) throws IOException { if (request.getParameter("offset") != null) { offset = Integer.parseInt(request.getParameter("offset")); }//ww w . ja v a2 s . co m int count = -1; // parse them to Date, null is acceptable DateFormat format = new SimpleDateFormat("MM/dd/yyyy"); // Get the from date and to date Date to = null; Date from = null; try { from = format.parse(request.getParameter("datepickerFrom")); } catch (Exception e) { //System.out.println("======From Date Empty======="); } try { to = format.parse(request.getParameter("datepickerTo")); } catch (Exception e) { //System.out.println("======To Date Empty======="); } if (orderAccessData == null || orderAccessData.size() == 0) { // get all the records in the date range orderAccessData = ((OrderAccessService) Context.getService(OrderAccessService.class)) .getOrderAccessesByAccessDateOrderByPatientId(from, to); if (orderAccessData == null) { orderAccessData = new ArrayList<OrderServiceAccess>(); } } // get date for small graph Date toSmall = to; Date fromSmall = null; Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, 1); if (toSmall == null) { toSmall = calendar.getTime(); } else { calendar.setTime(toSmall); } calendar.add(Calendar.DATE, -DAYNUM); fromSmall = calendar.getTime(); List<String> dateStrings = new ArrayList<String>(); for (int i = 0; i < DAYNUM; i++) { if (i == DAYNUM - 1) { dateStrings.add(format.format(toSmall)); } else if (i == 0) { dateStrings.add(format.format(fromSmall)); } else { dateStrings.add(""); } } ArrayList<ArrayList<Integer>> tooltip = new ArrayList<ArrayList<Integer>>(); tooltip.add(new ArrayList<Integer>()); for (int j = 0; j < SHOWNUM + 1; j++) { tooltip.get(0).add(1000 + j); } for (int i = 1; i < DAYNUM + 1; i++) { tooltip.add(new ArrayList<Integer>()); tooltip.get(i).add(i); for (int j = 0; j < SHOWNUM; j++) { tooltip.get(i).add(0); } } ArrayList<String> patientIds = new ArrayList<String>(); ArrayList<Integer> patientCounts = new ArrayList<Integer>(); String last = ""; for (OrderServiceAccess oa : orderAccessData) { // data for big graph String idString = (oa.getPatientId() == null) ? "No ID" : oa.getPatientId().toString(); if (!idString.equals(last)) { count++; last = idString; } int index = patientIds.indexOf(idString); if (index < 0) { if (count < offset) continue; if (patientIds.size() >= SHOWNUM) break; patientIds.add(idString); patientCounts.add(1); index = patientIds.size() - 1;//index = personIds.indexOf(idString); } else { patientCounts.set(index, patientCounts.get(index) + 1); } // data for small graph if (oa.getAccessDate().after(fromSmall) && oa.getAccessDate().before(toSmall)) { int index2 = (int) ((oa.getAccessDate().getTime() - fromSmall.getTime()) / (1000 * 60 * 60 * 24)); if (index2 < DAYNUM && index2 >= 0) tooltip.get(index2 + 1).set(index + 1, tooltip.get(index2 + 1).get(index + 1) + 1); } } String patientIdString = JSONValue.toJSONString(patientIds); String patientCountString = JSONValue.toJSONString(patientCounts); String dateSmallString = JSONValue.toJSONString(dateStrings); String tooltipdata = JSONValue.toJSONString(tooltip); model.addAttribute("patientIds", patientIdString); model.addAttribute("patientCounts", patientCountString); model.addAttribute("dateSmallString", dateSmallString); model.addAttribute("tooltipdata", tooltipdata); model.addAttribute("user", Context.getAuthenticatedUser()); //model.addAttribute("tables1", orderAccessData); //model.addAttribute("dateSmall", dateStrings); model.addAttribute("currentoffset", String.valueOf(offset)); }
From source file:org.openmrs.module.accessmonitor.web.controller.AccessMonitorPersonController.java
@RequestMapping(value = "/module/accessmonitor/person", method = RequestMethod.GET) public void person(ModelMap model, HttpServletRequest request) { offset = 0;//from w ww . j a va2s . c o m // parse them to Date, null is acceptabl DateFormat format = new SimpleDateFormat("MM/dd/yyyy"); // Get the from date and to date Date to = null; Date from = null; try { from = format.parse(request.getParameter("datepickerFrom")); } catch (Exception e) { //System.out.println("======From Date Empty======="); } try { to = format.parse(request.getParameter("datepickerTo")); } catch (Exception e) { //System.out.println("======To Date Empty======="); } // get all the records in the date range personAccessData = ((PersonAccessService) Context.getService(PersonAccessService.class)) .getPersonAccessesByAccessDateOrderByPersonId(from, to); if (personAccessData == null) { personAccessData = new ArrayList<PersonServiceAccess>(); } // get date for small graph Date toSmall = to; Date fromSmall = null; Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, 1); if (toSmall == null) { toSmall = calendar.getTime(); } else { calendar.setTime(toSmall); } calendar.add(Calendar.DATE, -DAYNUM); fromSmall = calendar.getTime(); List<String> dateStrings = new ArrayList<String>(); for (int i = 0; i < DAYNUM; i++) { if (i == DAYNUM - 1) { dateStrings.add(format.format(toSmall)); } else if (i == 0) { dateStrings.add(format.format(fromSmall)); } else { dateStrings.add(""); } } ArrayList<ArrayList<Integer>> tooltip = new ArrayList<ArrayList<Integer>>(); tooltip.add(new ArrayList<Integer>()); for (int j = 0; j < SHOWNUM + 1; j++) { tooltip.get(0).add(1000 + j); } for (int i = 1; i < DAYNUM + 1; i++) { tooltip.add(new ArrayList<Integer>()); tooltip.get(i).add(i); for (int j = 0; j < SHOWNUM; j++) { tooltip.get(i).add(0); } } ArrayList<String> personIds = new ArrayList<String>(); ArrayList<Integer> personCounts = new ArrayList<Integer>(); for (PersonServiceAccess pa : personAccessData) { // data for big graph String idString = (pa.getPersonId() == null) ? "No ID" : pa.getPersonId().toString(); int index = personIds.indexOf(idString); if (index < 0) { if (personIds.size() >= SHOWNUM) break; personIds.add(idString); personCounts.add(1); index = personIds.size() - 1;//index = personIds.indexOf(idString); } else { personCounts.set(index, personCounts.get(index) + 1); } // data for small graph if (pa.getAccessDate().after(fromSmall) && pa.getAccessDate().before(toSmall)) { int index2 = (int) ((pa.getAccessDate().getTime() - fromSmall.getTime()) / (1000 * 60 * 60 * 24)); if (index2 < DAYNUM && index2 >= 0) tooltip.get(index2 + 1).set(index + 1, tooltip.get(index2 + 1).get(index + 1) + 1); } } String personIdString = JSONValue.toJSONString(personIds); String personCountString = JSONValue.toJSONString(personCounts); String dateSmallString = JSONValue.toJSONString(dateStrings); String tooltipdata = JSONValue.toJSONString(tooltip); model.addAttribute("personIds", personIdString); model.addAttribute("personCounts", personCountString); model.addAttribute("dateSmallString", dateSmallString); model.addAttribute("tooltipdata", tooltipdata); model.addAttribute("user", Context.getAuthenticatedUser()); //model.addAttribute("tables1", personAccessData); //model.addAttribute("dateSmall", dateStrings); model.addAttribute("currentoffset", String.valueOf(offset)); }
From source file:org.openmrs.module.accessmonitor.web.controller.AccessMonitorPersonController.java
@RequestMapping(value = "/module/accessmonitor/person", method = RequestMethod.POST) public void postSave(ModelMap model, HttpServletRequest request) throws IOException { if (request.getParameter("offset") != null) { offset = Integer.parseInt(request.getParameter("offset")); }//from w w w . ja v a 2s . c o m int count = -1; // parse them to Date, null is acceptabl DateFormat format = new SimpleDateFormat("MM/dd/yyyy"); // Get the from date and to date Date to = null; Date from = null; try { from = format.parse(request.getParameter("datepickerFrom")); } catch (Exception e) { //System.out.println("======From Date Empty======="); } try { to = format.parse(request.getParameter("datepickerTo")); } catch (Exception e) { //System.out.println("======To Date Empty======="); } // get all the records in the date range if (personAccessData == null || personAccessData.size() == 0) { personAccessData = ((PersonAccessService) Context.getService(PersonAccessService.class)) .getPersonAccessesByAccessDateOrderByPersonId(from, to); if (personAccessData == null) { personAccessData = new ArrayList<PersonServiceAccess>(); } } // get date for small graph Date toSmall = to; Date fromSmall = null; Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, 1); if (toSmall == null) { toSmall = calendar.getTime(); } else { calendar.setTime(toSmall); } calendar.add(Calendar.DATE, -DAYNUM); fromSmall = calendar.getTime(); List<String> dateStrings = new ArrayList<String>(); for (int i = 0; i < DAYNUM; i++) { if (i == DAYNUM - 1) { dateStrings.add(format.format(toSmall)); } else if (i == 0) { dateStrings.add(format.format(fromSmall)); } else { dateStrings.add(""); } } ArrayList<ArrayList<Integer>> tooltip = new ArrayList<ArrayList<Integer>>(); tooltip.add(new ArrayList<Integer>()); for (int j = 0; j < SHOWNUM + 1; j++) { tooltip.get(0).add(1000 + j); } for (int i = 1; i < DAYNUM + 1; i++) { tooltip.add(new ArrayList<Integer>()); tooltip.get(i).add(i); for (int j = 0; j < SHOWNUM; j++) { tooltip.get(i).add(0); } } ArrayList<String> personIds = new ArrayList<String>(); ArrayList<Integer> personCounts = new ArrayList<Integer>(); String last = ""; for (PersonServiceAccess pa : personAccessData) { // data for big graph String idString = (pa.getPersonId() == null) ? "No ID" : pa.getPersonId().toString(); if (!idString.equals(last)) { count++; last = idString; } int index = personIds.indexOf(idString); if (index < 0) { if (count < offset) continue; if (personIds.size() >= SHOWNUM) break; personIds.add(idString); personCounts.add(1); index = personIds.size() - 1;//index = personIds.indexOf(idString); } else { personCounts.set(index, personCounts.get(index) + 1); } // data for small graph if (pa.getAccessDate().after(fromSmall) && pa.getAccessDate().before(toSmall)) { int index2 = (int) ((pa.getAccessDate().getTime() - fromSmall.getTime()) / (1000 * 60 * 60 * 24)); if (index2 < DAYNUM && index2 >= 0) tooltip.get(index2 + 1).set(index + 1, tooltip.get(index2 + 1).get(index + 1) + 1); } } String personIdString = JSONValue.toJSONString(personIds); String personCountString = JSONValue.toJSONString(personCounts); String dateSmallString = JSONValue.toJSONString(dateStrings); String tooltipdata = JSONValue.toJSONString(tooltip); model.addAttribute("personIds", personIdString); model.addAttribute("personCounts", personCountString); model.addAttribute("dateSmallString", dateSmallString); model.addAttribute("tooltipdata", tooltipdata); model.addAttribute("user", Context.getAuthenticatedUser()); //model.addAttribute("tables1", personAccessData); //model.addAttribute("dateSmall", dateStrings); model.addAttribute("currentoffset", String.valueOf(offset)); }
From source file:org.openmrs.module.accessmonitor.web.controller.AccessMonitorVisitController.java
@RequestMapping(value = "/module/accessmonitor/visit", method = RequestMethod.GET) public void person(ModelMap model, HttpServletRequest request) { // ((OrderAccessService) Context.getService(OrderAccessService.class)).generateData(); // ((VisitAccessService) Context.getService(VisitAccessService.class)).generateData(); // ((PersonAccessService) Context.getService(PersonAccessService.class)).generateData(); offset = 0;//from w ww . java2s . co m // parse them to Date, null is acceptabl DateFormat format = new SimpleDateFormat("MM/dd/yyyy"); // Get the from date and to date Date to = null; Date from = null; try { from = format.parse(request.getParameter("datepickerFrom")); } catch (Exception e) { //System.out.println("======From Date Empty======="); } try { to = format.parse(request.getParameter("datepickerTo")); } catch (Exception e) { //System.out.println("======To Date Empty======="); } // get all the records in the date range visitAccessData = ((VisitAccessService) Context.getService(VisitAccessService.class)) .getVisitAccessesByAccessDateOrderByPatientId(from, to); if (visitAccessData == null) { visitAccessData = new ArrayList<VisitServiceAccess>(); } // get date for small graph Date toSmall = to; Date fromSmall = null; Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, 1); if (toSmall == null) { toSmall = calendar.getTime(); } else { calendar.setTime(toSmall); } calendar.add(Calendar.DATE, -DAYNUM); fromSmall = calendar.getTime(); List<String> dateStrings = new ArrayList<String>(); for (int i = 0; i < DAYNUM; i++) { if (i == DAYNUM - 1) { dateStrings.add(format.format(toSmall)); } else if (i == 0) { dateStrings.add(format.format(fromSmall)); } else { dateStrings.add(""); } } ArrayList<ArrayList<Integer>> tooltip = new ArrayList<ArrayList<Integer>>(); tooltip.add(new ArrayList<Integer>()); for (int j = 0; j < SHOWNUM + 1; j++) { tooltip.get(0).add(1000 + j); } for (int i = 1; i < DAYNUM + 1; i++) { tooltip.add(new ArrayList<Integer>()); tooltip.get(i).add(i); for (int j = 0; j < SHOWNUM; j++) { tooltip.get(i).add(0); } } ArrayList<String> patientIds = new ArrayList<String>(); ArrayList<Integer> patientCounts = new ArrayList<Integer>(); for (VisitServiceAccess va : visitAccessData) { // data for big graph String idString = (va.getPatientId() == null) ? "No ID" : va.getPatientId().toString(); int index = patientIds.indexOf(idString); if (index < 0) { if (patientIds.size() >= SHOWNUM) break; patientIds.add(idString); patientCounts.add(1); index = patientIds.size() - 1;//index = patientIds.indexOf(idString); } else { patientCounts.set(index, patientCounts.get(index) + 1); } // data for small graph if (va.getAccessDate().after(fromSmall) && va.getAccessDate().before(toSmall)) { int index2 = (int) ((va.getAccessDate().getTime() - fromSmall.getTime()) / (1000 * 60 * 60 * 24)); if (index2 < DAYNUM && index2 >= 0) tooltip.get(index2 + 1).set(index + 1, tooltip.get(index2 + 1).get(index + 1) + 1); } } String patientIdString = JSONValue.toJSONString(patientIds); String patientCountString = JSONValue.toJSONString(patientCounts); String dateSmallString = JSONValue.toJSONString(dateStrings); String tooltipdata = JSONValue.toJSONString(tooltip); model.addAttribute("patientIds", patientIdString); model.addAttribute("patientCounts", patientCountString); model.addAttribute("dateSmallString", dateSmallString); model.addAttribute("tooltipdata", tooltipdata); model.addAttribute("user", Context.getAuthenticatedUser()); // model.addAttribute("tables1", visitAccessData); // model.addAttribute("dateSmall", dateStrings); model.addAttribute("currentoffset", String.valueOf(offset)); }
From source file:org.openmrs.module.accessmonitor.web.controller.AccessMonitorVisitController.java
@RequestMapping(value = "/module/accessmonitor/visit", method = RequestMethod.POST) public void postSave(ModelMap model, HttpServletRequest request) throws IOException { if (request.getParameter("offset") != null) { offset = Integer.parseInt(request.getParameter("offset")); }/*from w w w . j a va2 s . co m*/ int count = -1; // parse them to Date, null is acceptabl DateFormat format = new SimpleDateFormat("MM/dd/yyyy"); // Get the from date and to date Date to = null; Date from = null; try { from = format.parse(request.getParameter("datepickerFrom")); } catch (Exception e) { //System.out.println("======From Date Empty======="); } try { to = format.parse(request.getParameter("datepickerTo")); } catch (Exception e) { //System.out.println("======To Date Empty======="); } if (visitAccessData == null || visitAccessData.size() == 0) { // get all the records in the date range visitAccessData = ((VisitAccessService) Context.getService(VisitAccessService.class)) .getVisitAccessesByAccessDateOrderByPatientId(from, to); if (visitAccessData == null) { visitAccessData = new ArrayList<VisitServiceAccess>(); } } // get date for small graph Date toSmall = to; Date fromSmall = null; Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, 1); if (toSmall == null) { toSmall = calendar.getTime(); } else { calendar.setTime(toSmall); } calendar.add(Calendar.DATE, -DAYNUM); fromSmall = calendar.getTime(); List<String> dateStrings = new ArrayList<String>(); for (int i = 0; i < DAYNUM; i++) { if (i == DAYNUM - 1) { dateStrings.add(format.format(toSmall)); } else if (i == 0) { dateStrings.add(format.format(fromSmall)); } else { dateStrings.add(""); } } ArrayList<ArrayList<Integer>> tooltip = new ArrayList<ArrayList<Integer>>(); tooltip.add(new ArrayList<Integer>()); for (int j = 0; j < SHOWNUM + 1; j++) { tooltip.get(0).add(1000 + j); } for (int i = 1; i < DAYNUM + 1; i++) { tooltip.add(new ArrayList<Integer>()); tooltip.get(i).add(i); for (int j = 0; j < SHOWNUM; j++) { tooltip.get(i).add(0); } } ArrayList<String> patientIds = new ArrayList<String>(); ArrayList<Integer> patientCounts = new ArrayList<Integer>(); String last = ""; for (VisitServiceAccess va : visitAccessData) { // data for big graph String idString = (va.getPatientId() == null) ? "No ID" : va.getPatientId().toString(); if (!idString.equals(last)) { count++; last = idString; } int index = patientIds.indexOf(idString); if (index < 0) { if (count < offset) continue; if (patientIds.size() >= SHOWNUM) break; patientIds.add(idString); patientCounts.add(1); index = patientIds.size() - 1;//index = patientIds.indexOf(idString); } else { patientCounts.set(index, patientCounts.get(index) + 1); } // data for small graph if (va.getAccessDate().after(fromSmall) && va.getAccessDate().before(toSmall)) { int index2 = (int) ((va.getAccessDate().getTime() - fromSmall.getTime()) / (1000 * 60 * 60 * 24)); if (index2 < DAYNUM && index2 >= 0) tooltip.get(index2 + 1).set(index + 1, tooltip.get(index2 + 1).get(index + 1) + 1); } } String patientIdString = JSONValue.toJSONString(patientIds); String patientCountString = JSONValue.toJSONString(patientCounts); String dateSmallString = JSONValue.toJSONString(dateStrings); String tooltipdata = JSONValue.toJSONString(tooltip); model.addAttribute("patientIds", patientIdString); model.addAttribute("patientCounts", patientCountString); model.addAttribute("dateSmallString", dateSmallString); model.addAttribute("tooltipdata", tooltipdata); model.addAttribute("user", Context.getAuthenticatedUser()); // model.addAttribute("tables1", visitAccessData); // model.addAttribute("dateSmall", dateStrings); model.addAttribute("currentoffset", String.valueOf(offset)); }
From source file:org.pentaho.osgi.platform.plugin.deployer.impl.JSONUtil.java
public String prettyPrintMapStringString(Map<String, String> map) { StringBuilder sb = new StringBuilder(); appendOpen(sb);//w w w .j av a2 s. co m for (Map.Entry<String, String> entry : map.entrySet()) { writeKeyAndSeparator(sb, entry.getKey(), 2); sb.append(JSONValue.toJSONString(entry.getValue())); sb.append(",\n"); } if (map.size() > 0) { sb.setLength(sb.length() - 2); } appendClose(sb); return sb.toString(); }
From source file:org.pentaho.osgi.platform.plugin.deployer.impl.JSONUtil.java
private void writeKeyAndSeparator(StringBuilder stringBuilder, String key, int spaceBefore) { for (int i = 0; i < spaceBefore; i++) { stringBuilder.append(' '); }// w ww. ja v a 2s . c o m stringBuilder.append(JSONValue.toJSONString(key)); stringBuilder.append(" : "); }
From source file:org.pentaho.osgi.platform.plugin.deployer.impl.JSONUtil.java
private void writeListOfStrings(StringBuilder stringBuilder, List<String> list, int spaceBefore) { stringBuilder.append("[ \n"); for (String entry : list) { for (int i = 0; i < spaceBefore; i++) { stringBuilder.append(' '); }/* w w w.java 2 s. com*/ stringBuilder.append(JSONValue.toJSONString(entry)); stringBuilder.append(",\n"); } stringBuilder.setLength(stringBuilder.length() - 2); stringBuilder.append(" ]"); }
From source file:org.royaldev.royalcommands.tools.UUIDFetcher.java
@SuppressWarnings("unchecked") private static String buildBody(final List<String> names) { final List<JSONObject> lookups = new ArrayList<>(); for (final String name : names) { final JSONObject obj = new JSONObject(); obj.put("name", name); obj.put("agent", UUIDFetcher.AGENT); lookups.add(obj);/*from ww w. ja va2 s . com*/ } return JSONValue.toJSONString(lookups); }