Package org.codehaus.jackson.map

Examples of org.codehaus.jackson.map.ObjectMapper


  public void testPutSingleSerializableVariable() throws Exception {

    ArrayList<String> serializable = new ArrayList<String>();
    serializable.add("foo");

    ObjectMapper mapper = new ObjectMapper();
    String jsonBytes = mapper.writeValueAsString(serializable);
    String typeName = TypeFactory.type(serializable.getClass()).toCanonical();

    String variableKey = "aVariableKey";

    given()
View Full Code Here


  public void testPutSingleSerializableVariableUnsupportedMediaType() throws Exception {

    ArrayList<String> serializable = new ArrayList<String>();
    serializable.add("foo");

    ObjectMapper mapper = new ObjectMapper();
    String jsonBytes = mapper.writeValueAsString(serializable);
    String typeName = TypeFactory.type(serializable.getClass()).toCanonical();

    String variableKey = "aVariableKey";

    given()
View Full Code Here

  }

  @Test @DirtiesContext
  public void createBook() throws Exception {
    Book book = new Book("Pro Struts", new Author("Rob", "Harrop"));
    ObjectMapper mapper = new ObjectMapper();
    String content = mapper.writeValueAsString(book);
    mockMvc.perform(post("/books")
        .content(content)
        .contentType(MediaType.APPLICATION_JSON))
        .andExpect(status().isCreated());
    assertNotNull(this.repository.findById(2));
View Full Code Here

  }

  @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

        HIHOConf.INPUT_OUTPUT_DELIMITER);
    logger.debug("delimiter is: " + delimiter);
    String columnInfoJsonString = context.getConfiguration().get(
        HIHOConf.COLUMN_INFO);
    logger.debug("columnInfoJsonString is: " + columnInfoJsonString);
    ObjectMapper mapper = new ObjectMapper();
    tableInfo = mapper.readValue(columnInfoJsonString,
        new TypeReference<ArrayList<ColumnInfo>>() {
        });
  }
View Full Code Here

    public void testToParseEnqueteAnswers() throws JsonParseException, JsonMappingException, IOException {
        UUID[] ids = new UUID[5];
        for (int i = 0; i < 5; ++i)
            ids[i] = new UUID(0, i);

        ObjectNode obj = new ObjectMapper().readValue("{ \""+ids[0].toString()+"\": [\"hoge\", \"fuga\"], " +
                "\""+ids[1].toString()+"\": [1, 2, 3], " +
                "\""+ids[2].toString()+"\": [], " +
                "\""+ids[3].toString()+"\": \"\", " +
                "\""+ids[4].toString()+"\": 3 " +
                "}", ObjectNode.class);
View Full Code Here

     * @return
     * @throws IOException
     */
    protected ObjectNode getJSON(ActionProxy proxy) throws Exception {
        String str = getJSONString(proxy);
        return new ObjectMapper().readValue(str, ObjectNode.class);
    }
View Full Code Here

    tableInfo.add(columnInfo2);
    tableInfo.add(columnInfo3);
    //tableInfo.add(columnInfo4);
    tableInfo.add(columnInfo5);
   
    ObjectMapper objectMapper = new ObjectMapper();     
    JsonFactory jsonFactory = new JsonFactory()
    StringWriter writer = new StringWriter();
    JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(writer);
    objectMapper.writeValue(jsonGenerator, tableInfo);
    String jsonString = writer.toString();
    when(context.getConfiguration().get(HIHOConf.COLUMN_INFO)).thenReturn(jsonString);
   
    mapper.setup(context);
    assertEquals(mapper.getTableInfo().toString(), tableInfo.toString());
View Full Code Here

      String response = HTTPUtils.getMethod(new URL("http://reiseauskunft.bahn.de/bin/ajax-getstop.exe/dn?start=1&tpl=sls&REQ0JourneyStopsB=12&REQ0JourneyStopsS0A=1&getstop=1&noSession=yes&iER=yes&S=" + contains + "?&js=true"));
 
      Matcher matcher = pattern.matcher(response);
      if(matcher.find()) {
        String filter = matcher.group();
        ObjectMapper m = new ObjectMapper();
        try {
          StationVO stations[] = m.readValue(filter, StationVO[].class);
          return Arrays.asList(stations);
        } catch (Exception e) {
          StationServerResource.log.severe("could not parse object to stationvo: " + e.toString());
        }
      } else {
View Full Code Here

 
  private boolean debug = false;
 
  public EndpointExceptionResolver() {
    view = new MappingJacksonJsonView();
    ObjectMapper om = new EndpointObjectMapper();
    view.setObjectMapper(om);
    view.setExtractValueFromSingleKeyModel(true);
  }
View Full Code Here

TOP

Related Classes of org.codehaus.jackson.map.ObjectMapper

Copyright © 2018 www.massapicom. 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.