コード例 #1
0
 private String _returnPublication(HttpServletRequest req, Publication pub) {
   // to json
   RestfulPublication result = new RestfulPublication(pub);
   Gson jsonBuilder = support.getJsonBuilder(request, RestfulPublication.FIELD_SELECTOR);
   String json = jsonBuilder.toJson(result, RestfulPublication.class);
   return support.wrapReturn(request, String.format("[%s]", json));
 }
コード例 #2
0
  private String _returnPublication(HttpServletRequest req, Publication[] pubs) {
    if (null == pubs) {
      return "[]";
    }
    System.out.println(">>" + pubs.length);
    List<RestfulPublication> rPubs = new ArrayList<RestfulPublication>(pubs.length);
    for (Publication pub : pubs) {
      RestfulPublication rPub = new RestfulPublication(pub);
      rPubs.add(rPub);
    }

    Gson jsonBuilder = support.getJsonBuilder(request, RestfulPublication.FIELD_SELECTOR);

    Type type = new TypeToken<List<RestfulPublication>>() {}.getType();

    String json = jsonBuilder.toJson(rPubs, type);
    return support.wrapReturn(request, json);
  }