Package com.fasterxml.jackson.databind

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


  public void testSerializationOfSingleStepExecution() throws JsonProcessingException {

    final ObjectMapper objectMapper = new ObjectMapper();

    objectMapper.addMixInAnnotations(StepExecution.class, StepExecutionJacksonMixIn.class);
    objectMapper.addMixInAnnotations(ExecutionContext.class, ExecutionContextJacksonMixIn.class);

    final StepExecution stepExecution = getStepExecution();
    final String result = objectMapper.writeValueAsString(stepExecution);

    assertThat(result, not(containsString("\"executionContext\":{\"dirty\":true,\"empty\":false}")));
View Full Code Here


    String jsonConfig;
    if (!doc) {
      jsonConfig = configurationService.getJsonHandler().writeValueAsString(remotingApi, debug);
    } else {
      ObjectMapper mapper = new ObjectMapper();
      mapper.addMixInAnnotations(RemotingApi.class, RemotingApiMixin.class);
      try {
        jsonConfig = mapper.writer().withDefaultPrettyPrinter().writeValueAsString(remotingApi);
      } catch (JsonProcessingException e) {
        jsonConfig = null;
        LogFactory.getLog(ApiController.class).info("serialize object to json", e);
View Full Code Here

    String jsonConfig;
    if (!doc) {
      jsonConfig = configurationService.getJsonHandler().writeValueAsString(remotingApi, debug);
    } else {
      ObjectMapper mapper = new ObjectMapper();
      mapper.addMixInAnnotations(RemotingApi.class, RemotingApiMixin.class);
      try {
        jsonConfig = mapper.writer().withDefaultPrettyPrinter().writeValueAsString(remotingApi);
      } catch (JsonProcessingException e) {
        jsonConfig = null;
        LogFactory.getLog(ApiController.class).info("serialize object to json", e);
View Full Code Here

    String jsonConfig;
    if (!doc) {
      jsonConfig = configurationService.getJsonHandler().writeValueAsString(remotingApi, debug);
    } else {
      ObjectMapper mapper = new ObjectMapper();
      mapper.addMixInAnnotations(RemotingApi.class, RemotingApiMixin.class);
      try {
        jsonConfig = mapper.writer().withDefaultPrettyPrinter().writeValueAsString(remotingApi);
      } catch (JsonProcessingException e) {
        jsonConfig = null;
        LogFactory.getLog(ApiController.class).info("serialize object to json", e);
View Full Code Here

    String jsonConfig;
    if (!doc) {
      jsonConfig = configurationService.getJsonHandler().writeValueAsString(remotingApi, debug);
    } else {
      ObjectMapper mapper = new ObjectMapper();
      mapper.addMixInAnnotations(RemotingApi.class, RemotingApiMixin.class);
      try {
        jsonConfig = mapper.writer().withDefaultPrettyPrinter().writeValueAsString(remotingApi);
      } catch (JsonProcessingException e) {
        jsonConfig = null;
        LogFactory.getLog(ApiController.class).info("serialize object to json", e);
View Full Code Here

    String jsonConfig;
    if (!doc) {
      jsonConfig = configurationService.getJsonHandler().writeValueAsString(remotingApi, debug);
    } else {
      ObjectMapper mapper = new ObjectMapper();
      mapper.addMixInAnnotations(RemotingApi.class, RemotingApiMixin.class);
      try {
        jsonConfig = mapper.writer().withDefaultPrettyPrinter().writeValueAsString(remotingApi);
      } catch (JsonProcessingException e) {
        jsonConfig = null;
        LogFactory.getLog(ApiController.class).info("serialize object to json", e);
View Full Code Here

    String jsonConfig;
    if (!doc) {
      jsonConfig = configurationService.getJsonHandler().writeValueAsString(remotingApi, debug);
    } else {
      ObjectMapper mapper = new ObjectMapper();
      mapper.addMixInAnnotations(RemotingApi.class, RemotingApiMixin.class);
      try {
        jsonConfig = mapper.writer().withDefaultPrettyPrinter().writeValueAsString(remotingApi);
      } catch (JsonProcessingException e) {
        jsonConfig = null;
        LogFactory.getLog(ApiController.class).info("serialize object to json", e);
View Full Code Here

  @Test
  public void serializerWithMixin() throws Exception {
    DataSource dataSource = new DataSource();
    ObjectMapper mapper = new ObjectMapper();
    mapper.addMixInAnnotations(DataSource.class, DataSourceJson.class);
    String value = mapper.writeValueAsString(dataSource);
    assertTrue(value.contains("\"url\":"));
    assertEquals(1, StringUtils.countOccurrencesOf(value, "\"url\""));
  }
View Full Code Here

      jsonConfig = configurationService.getJsonHandler().writeValueAsString(
          remotingApi, debug);
    }
    else {
      ObjectMapper mapper = new ObjectMapper();
      mapper.addMixInAnnotations(RemotingApi.class, RemotingApiMixin.class);
      try {
        jsonConfig = mapper.writer().withDefaultPrettyPrinter()
            .writeValueAsString(remotingApi);
      }
      catch (JsonProcessingException e) {
View Full Code Here

    }

    @Test
    public final void givenFieldTypeIsIgnored_whenDtoIsSerialized_thenCorrect() throws JsonParseException, IOException {
        final ObjectMapper mapper = new ObjectMapper();
        mapper.addMixInAnnotations(String.class, MyMixInForString.class);
        final MyDto dtoObject = new MyDto();
        dtoObject.setBooleanValue(true);

        final String dtoAsString = mapper.writeValueAsString(dtoObject);
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.