Examples of writeValueAsString()


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

  @Test @DirtiesContext
  public void updateBook() throws Exception {
    Book book = new Book("Pro Struts", new Author("Rob", "Harrop"));
    ObjectMapper mapper = new ObjectMapper();
    String content = mapper.writeValueAsString(book);
    mockMvc.perform(put("/books/{id}", 1)
        .content(content)
        .contentType(MediaType.APPLICATION_JSON))
        .andExpect(status().isNoContent());
    assertEquals("Pro Struts", this.repository.findById(1).getTitle());
View Full Code Here

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

    tasks.put(taskName, taskModel);
    ContainerModel containerModel = new ContainerModel(1, tasks);
    Map<Integer, ContainerModel> containerMap = new HashMap<Integer, ContainerModel>();
    containerMap.put(Integer.valueOf(1), containerModel);
    JobModel jobModel = new JobModel(config, containerMap);
    String str = mapper.writeValueAsString(jobModel);
    JobModel obj = mapper.readValue(str, JobModel.class);
    assertEquals(jobModel, obj);
  }
}
View Full Code Here

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

    mapper.registerModule(module);
    mapper.getSerializationConfig().setSerializationInclusion(Inclusion.NON_NULL);

    String json = null;
    try {
      json = mapper.writeValueAsString(object);
    } catch (Exception e) {
      throw new RuntimeException("Error encoding object: " + object + " into JSON string", e);
    }
    return json;
  }
View Full Code Here

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

        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

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

          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

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

      } 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

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

      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

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

      x.s = "abc";
      x.b = true;
      x.x = new MyClass();

      ObjectMapper objMapper = new ObjectMapper().enableDefaultTyping(DefaultTyping.NON_FINAL, JsonTypeInfo.As.WRAPPER_OBJECT);
      String s = objMapper.writeValueAsString(x);
      System.out.println(s);
      Object readValue = objMapper.readValue(s, Object.class);
      System.out.println(readValue.getClass().getName());
   }
}
View Full Code Here

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

     */
    private String toJSONString(Object value) {
        ObjectMapper om = new ObjectMapper();
        String stringPayload = null;
        try {
            stringPayload = om.writeValueAsString(value);
        } catch (Exception e) {
            throw new IllegalStateException("Failed to encode JSON payload");
        }
        return stringPayload;
    }
View Full Code Here

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

  public static void main(final String[] args) throws Exception {
    // given
    WebClient rsclient = WebClient.create("http://localhost:7070/next-app/services/rest", "admin", "admin", null);
    ObjectMapper objectMapper = new ObjectMapper();
    String writeValueAsString = objectMapper.writeValueAsString(new CustomerData("mirek", 27, BigDecimal.TEN));

    // when
    Response response =
        rsclient.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON_TYPE).path(
            "/command/execute/pl.com.stream.CustomerService/add").put(writeValueAsString);
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.