public String handle(Reader requestData) { Map<String, Long> checks = null; try { Gson gson = new Gson(); checks = gson.fromJson(GetPostData(requestData), postType()); } catch (Exception ex) { System.err.println(ex.getMessage()); } Integer count = 0; if (checks != null) { count = checks.size(); for (Map.Entry<String, Long> pairs : checks.entrySet()) { dataStore.saveRow("RejectChecks", pairs.getKey() + " = " + pairs.getValue().toString()); } } return "{\"count\":" + count.toString() + "}"; }
public String respond(Reader requestData) { long startTime = clock.currentTime(); Gson gson = new Gson(); List<String> checks = null; try { checks = gson.fromJson(GetPostData(requestData), requestType()); } catch (Exception ex) { System.err.println(ex.getMessage()); } LinkedHashMap<String, Long> map = new LinkedHashMap<String, Long>(); if (checks != null) { for (String amount : checks) { if (clock.IsOverTime(startTime)) { break; } Long parsedValue = checkParser.parseExpression(amount); if (parsedValue == null) { System.err.println("could not parse amount " + amount); } else { map.put(amount, parsedValue); } // don't save when upload google appengine // it will cause timeout issue !!! // dataStore.saveRow("Checks", amount); } } // if we want to display "&" rather than "\u0026" // return new GsonBuilder().disableHtmlEscaping().create().toString(map); return gson.toJson(map); }