Package org.codehaus.jackson.map

Examples of org.codehaus.jackson.map.ObjectMapper.writeValueAsString()


    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    }
    System.out.println("obj"+obj.toString()+" / "+mapper.writeValueAsString(obj));
    resp.setContentType("application/json");
    mapper.writeValue(resp.getWriter(), mapper.writeValueAsString(obj));
  }
}
View Full Code Here


  }
 
  public  <E extends JsonObject> String toJsonString(E obj){
    ObjectMapper mapper = new ObjectMapper();
    try {
      return mapper.writeValueAsString(obj);
    }catch (JsonMappingException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
View Full Code Here

        try {
            if (targetType != null && targetType.isPrimitive()) {
                return source;
            }
            ObjectMapper mapper = JacksonHelper.createObjectMapper(targetType);
            String value = mapper.writeValueAsString(source);
            if (JsonNode.class.isAssignableFrom(targetType)) {
                return JacksonHelper.createJsonParser(value).readValueAsTree();
            } else if (targetType == String.class || targetType == Object.class || targetType.isPrimitive()) {
                return value;
            } else if (targetType == BigDecimal.class) {
View Full Code Here

                    Class<?> returnClass = returnType.getPhysical();
                    Type genericReturnType = returnType.getGenericType();

                    ObjectMapper mapper = createObjectMapper(returnClass);
                    String json = mapper.writeValueAsString(rawResult);

                    Object body = mapper.readValue(json, TypeFactory.type(genericReturnType));

                    msg.setBody(body);
                } else {
View Full Code Here

      for (int i = 0; i < 10; i++) {
        for (int j = 0; j < opts.numClientThreads; j++) {
          TestOptions next = new TestOptions(opts);
          next.startRow = (j * perClientRows) + (i * (perClientRows/10));
          next.perClientRunRows = perClientRows / 10;
          String s = mapper.writeValueAsString(next);
          int hash = h.hash(Bytes.toBytes(s));
          m.put(hash, s);
        }
      }
      for (Map.Entry<Integer, String> e: m.entrySet()) {
View Full Code Here

        responseInfo.put("table", Bytes.toStringBinary(tableName));
        // annotate the response map with operation details
        responseInfo.putAll(((Operation) params[1]).toMap());
        // report to the log file
        LOG.warn("(operation" + tag + "): " +
            mapper.writeValueAsString(responseInfo));
      } else if (params.length == 1 && instance instanceof HRegionServer &&
          params[0] instanceof Operation) {
        // annotate the response map with operation details
        responseInfo.putAll(((Operation) params[0]).toMap());
        // report to the log file
View Full Code Here

          params[0] instanceof Operation) {
        // annotate the response map with operation details
        responseInfo.putAll(((Operation) params[0]).toMap());
        // report to the log file
        LOG.warn("(operation" + tag + "): " +
            mapper.writeValueAsString(responseInfo));
      } else {
        // can't get JSON details, so just report call.toString() along with
        // a more generic tag.
        responseInfo.put("call", call.toString());
        LOG.warn("(response" + tag + "): " +
View Full Code Here

      } else {
        // can't get JSON details, so just report call.toString() along with
        // a more generic tag.
        responseInfo.put("call", call.toString());
        LOG.warn("(response" + tag + "): " +
            mapper.writeValueAsString(responseInfo));
      }
    }
  }

  protected static void log(String value) {
View Full Code Here

  }

  @Override
  public String toJSON() throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    return mapper.writeValueAsString(toMap());
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder(512);
View Full Code Here

   * @param maxCols a limit on the number of columns to include in the JSON
   * @return a JSONObject containing this Operation's information, as a string
   */
  public String toJSON(int maxCols) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    return mapper.writeValueAsString(toMap(maxCols));
  }

  /**
   * Produces a JSON object sufficient for description of a query
   * in a debugging or logging context.
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.