Examples of writerWithDefaultPrettyPrinter()


Examples of com.fasterxml.jackson.databind.ObjectMapper.writerWithDefaultPrettyPrinter()

  }
 
  public static <T> String write(T object) {
    try {
      ObjectMapper mapper = new ObjectMapper();
      return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(object);
    } catch (IOException ioe) {
      throw new RuntimeException("Unable to generate JSON from object. Reason: " + ioe.getMessage(), ioe);
    }
  }
}
View Full Code Here

Examples of com.fasterxml.jackson.databind.ObjectMapper.writerWithDefaultPrettyPrinter()

    if (prettyPrint) {
      ObjectMapper mapper = new ObjectMapper();
      mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
      try {
        Object tmp = mapper.readValue(t.toString(), Object.class);
        json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(tmp);
      }
      catch (IOException e) {
        logger.error(e.getMessage(), e);
        return null;
      }
View Full Code Here

Examples of com.fasterxml.jackson.databind.ObjectMapper.writerWithDefaultPrettyPrinter()

    final StepExecutionInfoResource executionInfoResource2 = new StepExecutionInfoResource(123L, stepExecution2, "stepType");

    stepExecutionInfoResources.add(executionInfoResource1);
    stepExecutionInfoResources.add(executionInfoResource2);

    final String stepExecutionInfoResourcesAsJson = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(
        stepExecutionInfoResources);
    Assert.assertNotNull(stepExecutionInfoResourcesAsJson);
  }
}
View Full Code Here

Examples of com.fasterxml.jackson.databind.ObjectMapper.writerWithDefaultPrettyPrinter()

        Object[] args = { 1, null, 2 };
        String[] classes = { "java.lang.Integer", "java.lang.Integer", "java.lang.Integer" };
        MethodCall methodCall = new MethodCall("test", args, Arrays.asList(classes));

        ObjectMapper objectMapper = new ObjectMapper();
        String writeValueAsString = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(methodCall);
        MethodCall readValue = objectMapper.readValue(writeValueAsString, MethodCall.class);
        assertThat(readValue, is(methodCall));
    }

    @Test
View Full Code Here

Examples of com.fasterxml.jackson.databind.ObjectMapper.writerWithDefaultPrettyPrinter()

        BeanDescription auth = BeanDescription.fromObject(new Password("password"));
        methodCallRequest.setPrincipal("admin");
        methodCallRequest.setCredentials(auth);

        ObjectMapper mapper = new ObjectMapper();
        return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(methodCallRequest);
    }

    public static void createDeleteMessage() throws IOException {
        String connectorId = "example-remote";
        MethodCall methodCall = new MethodCall("delete", new Object[]{ connectorId });
View Full Code Here

Examples of com.fasterxml.jackson.databind.ObjectMapper.writerWithDefaultPrettyPrinter()

        MethodCallMessage methodCallRequest = new MethodCallMessage(methodCall, false);
        BeanDescription auth = BeanDescription.fromObject(new Password("password"));
        methodCallRequest.setPrincipal("admin");
        methodCallRequest.setCredentials(auth);
        ObjectMapper mapper = new ObjectMapper();
        String writeValueAsString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(methodCallRequest);
        System.out.println(writeValueAsString);
    }

    public static void createRegisterMessage() throws IOException {
        MethodCall methodCall = new MethodCall("registerConnector", new String[]{ "example-remote", "jms-json",
View Full Code Here

Examples of com.fasterxml.jackson.databind.ObjectMapper.writerWithDefaultPrettyPrinter()

        BeanDescription auth = BeanDescription.fromObject(new Password("password"));
        methodCallRequest.setPrincipal("admin");
        methodCallRequest.setCredentials(auth);

        ObjectMapper mapper = new ObjectMapper();
        String writeValueAsString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(methodCallRequest);
        System.out.println(writeValueAsString);
    }

    public static void main(String[] args) throws IOException {
        createRegisterMessage();
View Full Code Here

Examples of com.fasterxml.jackson.databind.ObjectMapper.writerWithDefaultPrettyPrinter()

    }

    String configObjectString;
    try {
      if (debug) {
        configObjectString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(modelObject);
      } else {
        configObjectString = mapper.writeValueAsString(modelObject);
      }

    } catch (JsonGenerationException e) {
View Full Code Here

Examples of com.fasterxml.jackson.databind.ObjectMapper.writerWithDefaultPrettyPrinter()

    }

    String configObjectString;
    try {
      if (config.isDebug()) {
        configObjectString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(modelObject);
      } else {
        configObjectString = mapper.writeValueAsString(modelObject);
      }

    } catch (JsonGenerationException e) {
View Full Code Here

Examples of com.fasterxml.jackson.databind.ObjectMapper.writerWithDefaultPrettyPrinter()

    }

    String configObjectString;
    try {
      if (config.isDebug()) {
        configObjectString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(modelObject);
      } else {
        configObjectString = mapper.writeValueAsString(modelObject);
      }

    } catch (JsonGenerationException e) {
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.