Examples of writerWithDefaultPrettyPrinter()


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

      Boolean oldValue = (Boolean) prefs.get("allow-anonymous-usage-tracking");
      // If value changed, write it to the file too
      if ((this.isAllowAnonymousTracking == null && oldValue != null)
              || (this.isAllowAnonymousTracking != null && !(this.isAllowAnonymousTracking.equals(oldValue)))) {
        prefs.put("allow-anonymous-usage-tracking", this.isAllowAnonymousTracking);
        om.writerWithDefaultPrettyPrinter().writeValue(preferenceFile.toFile(), prefs);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
View Full Code Here

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

      Boolean oldValue = (Boolean) prefs.get("advanced-mode");
      // If value changed, write it to the file too
      if ((this.isUseAdvancedMode == null && oldValue != null)
              || (this.isUseAdvancedMode != null && !(this.isUseAdvancedMode.equals(oldValue)))) {
        prefs.put("advanced-mode", this.isUseAdvancedMode);
        om.writerWithDefaultPrettyPrinter().writeValue(preferenceFile.toFile(), prefs);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
View Full Code Here

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

      if(resultFile.exists()) {
        resultFile.delete();
      }
      resultFile.createNewFile();

      mapper.writerWithDefaultPrettyPrinter().writeValue(resultFile, object);

    } catch(Exception e) {
      throw new PerfTestException("Cannot write object to file "+filename, e);

    }
View Full Code Here

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

    Reader input = new FileReader(inputFile);
    try {
      Writer output = new FileWriter(outputFile);
      try {
        ObjectMapper mapper = new ObjectMapper();
        ObjectWriter writer = mapper.writerWithDefaultPrettyPrinter();
        Iterator<Map> i = mapper.readValues(
                new JsonFactory().createJsonParser(input), Map.class);
        while (i.hasNext()) {
          Map m = i.next();
          output.write(writer.writeValueAsString(createSLSJob(m)) + EOL);
View Full Code Here

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

  private static void generateSLSNodeFile(String outputFile)
          throws IOException {
    Writer output = new FileWriter(outputFile);
    try {
      ObjectMapper mapper = new ObjectMapper();
      ObjectWriter writer = mapper.writerWithDefaultPrettyPrinter();
      for (Map.Entry<String, Set<String>> entry : rackNodeMap.entrySet()) {
        Map rack = new LinkedHashMap();
        rack.put("rack", entry.getKey());
        List nodes = new ArrayList();
        for (String name : entry.getValue()) {
View Full Code Here

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

      getLog().info("Writing results into " + outputFile.getName());
     
      try {
        ObjectMapper objectMapper = new ObjectMapper();
       
        ObjectWriter writer = objectMapper.writerWithDefaultPrettyPrinter();
       
        writer.writeValue(outputFile, result.getEnvironments());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
View Full Code Here

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

    }

    public String toJSON() {
        ObjectMapper mapper = new ObjectMapper();
        try {
            return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(this);
        } catch (IOException e) {
            e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
        }
        return "";
    }
View Full Code Here

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

    }

    public static void writePrettyPrint(Writer w, Object jsonObject) throws JsonGenerationException, JsonMappingException, IOException {
        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.getJsonFactory().disable(JsonGenerator.Feature.AUTO_CLOSE_TARGET);
        ObjectWriter objectWriter = objectMapper.writerWithDefaultPrettyPrinter();
       
        objectWriter.writeValue(w, jsonObject);
    }

    public static Object fromInputStream(InputStream content) throws IOException {
View Full Code Here

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

   */
  public static String formatJson(String json) {
    try {
      ObjectMapper mapper = new ObjectMapper();
      Object obj = new ObjectMapper().readValue(json, Object.class);
      return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(obj);
    } catch (Exception ex) {
      if (logger.isDebugEnabled()) {
        logger.debug("JSON String: " + json);
      }
      throw new JuRuntimeException("Couldn't format JSON (see debug log for JSON String)", ex);
View Full Code Here

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

    public String marshalToString(Object obj) {
      try {
        ObjectMapper mapper = new ObjectMapper();
        mapper.configure(SerializationConfig.Feature.SORT_PROPERTIES_ALPHABETICALLY, true);
        ObjectWriter writer = this.formattedOutput
          ? mapper.writerWithDefaultPrettyPrinter()
          : mapper.writer();
         
        return writer.writeValueAsString(obj);
      } catch (Exception ex) {
        throw new JuRuntimeException("Marshalling of object to JSON failed", ex);
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.