Package org.codehaus.jackson.map

Examples of org.codehaus.jackson.map.MappingJsonFactory.createJsonParser()


    public void testIncrementalPojoReading()
        throws IOException
    {
        JsonFactory jf = new MappingJsonFactory();
        final String JSON = "[ 1, true, null, \"abc\" ]";
        JsonParser jp = jf.createJsonParser(new StringReader(JSON));

        // let's advance past array start to prevent full binding
        assertToken(JsonToken.START_ARRAY, jp.nextToken());

        assertToken(JsonToken.VALUE_NUMBER_INT, jp.nextToken());
View Full Code Here


  }
     
  public static <T> T fromJson(byte[] in, Class<T> clazz) {
     MappingJsonFactory jsonFactory = new MappingJsonFactory(); // or, for data binding, org.codehaus.jackson.mapper.MappingJsonFactory
     try {
      JsonParser jp = jsonFactory.createJsonParser(in);
      return jp.readValueAs(clazz);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

  }
 
  public static <T> T fromJson(InputStream in, Class<T> clazz) {
     MappingJsonFactory jsonFactory = new MappingJsonFactory(); // or, for data binding, org.codehaus.jackson.mapper.MappingJsonFactory
     try {
      JsonParser jp = jsonFactory.createJsonParser(in);
      return jp.readValueAs(clazz);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
   
View Full Code Here

    @Override
    public T unmarshall(Class<T> clazz, String obj) {
        try {
            JsonFactory jsonFactory = new MappingJsonFactory();
            JsonParser jsonParser = jsonFactory.createJsonParser(new StringReader(obj));
            return jsonParser.readValueAs(clazz);
        } catch ( Exception e ) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

        Response r = client.accept("application/json")
            .type("application/json")
            .post(inputBean);
        assertEquals(Response.Status.OK.getStatusCode(), r.getStatus());
        MappingJsonFactory factory = new MappingJsonFactory();
        JsonParser parser = factory.createJsonParser((InputStream)r.getEntity());
        JsonBean output = parser.readValueAs(JsonBean.class);
        assertEquals("Maple", output.getVal2());
    }
}
View Full Code Here

      Map<String, Object> entry = new HashMap<String, Object>();
      MappingJsonFactory f = new MappingJsonFactory();
      JsonParser jp;
     
      try {
          jp = f.createJsonParser(fmJson);
      } catch (JsonParseException e) {
          throw new IOException(e);
      }
     
      jp.nextToken();
View Full Code Here

    return new JsonMapper().from(jsonTxt, eClass);
  }
 
  public EObject from(String jsonTxt, EClass eClass) throws IOException {
    JsonFactory f = new MappingJsonFactory();
    JsonParser jp = f.createJsonParser(jsonTxt.getBytes());
    return from(jp, eClass);
  }
 
  @SuppressWarnings({ "rawtypes", "unchecked" })
  private EObject from(JsonParser jp, EClass eClass) throws JsonParseException, IOException {
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.