Package org.codehaus.jackson.map

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


    StringWriter sw = new StringWriter();
    m.execute(sw, new ComplexObject());
    jg.writeEndObject();
    jg.flush();
    assertEquals(getContents(root, "complex.txt"), sw.toString());
    JsonNode jsonNode = jf.createJsonParser(json.toString()).readValueAsTree();
    Object o = JsonInterpreterTest.toObject(jsonNode);
    sw = new StringWriter();
    m = init().compile("complex.html");
    m.execute(sw, o);
    assertEquals(getContents(root, "complex.txt"), sw.toString());
View Full Code Here


  }

  private Object getScope() throws IOException {
    MappingJsonFactory jf = new MappingJsonFactory();
    InputStream json = getClass().getClassLoader().getResourceAsStream("hogan.json");
    final Map node = (Map) toObject(jf.createJsonParser(json).readValueAsTree());
    System.out.println(node);
    return new Object() {
      int uid = 0;
      List tweets = new ArrayList() {{
        for (int i = 0; i < 50; i++) {
View Full Code Here

    ));
    final Set<String> multiples = new HashSet<String>(Arrays.asList(
            "ZADD"
    ));
    JsonFactory jf = new MappingJsonFactory();
    JsonParser jsonParser = jf.createJsonParser(new URL("https://raw.github.com/antirez/redis-doc/master/commands.json"));
    final JsonNode commandNodes = jsonParser.readValueAsTree();
    Iterator<String> fieldNames = commandNodes.getFieldNames();
    ImmutableListMultimap<String,String> group = Multimaps.index(fieldNames,
            new Function<String, String>() {
              @Override
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

    @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

    @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

    public void testPojoReading()
        throws IOException
    {
        JsonFactory jf = new MappingJsonFactory();
        final String JSON = "{ \"x\" : 9 }";
        JsonParser jp = jf.createJsonParser(new StringReader(JSON));

        // let's try first by advancing:
        assertToken(JsonToken.START_OBJECT, jp.nextToken());
        Pojo p = jp.readValueAs(Pojo.class);
        assertEquals(9, p._x);
View Full Code Here

        Pojo p = jp.readValueAs(Pojo.class);
        assertEquals(9, p._x);
        jp.close();

        // and without
        jp = jf.createJsonParser(new StringReader(JSON));
        p = jp.readValueAs(Pojo.class);
        assertEquals(9, p._x);
        jp.close();
    }
View Full Code Here

    {
        JsonFactory jf = new MappingJsonFactory();
        final String JSON = "[ 1, 2, false ]";

        for (int i = 0; i < 2; ++i) {
            JsonParser jp = jf.createJsonParser(new StringReader(JSON));
            // whether to try advancing first or not? Try both
            if (i == 0) {
                assertToken(JsonToken.START_ARRAY, jp.nextToken());
            }
            JsonNode root = jp.readValueAsTree();
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.