Package com.fasterxml.jackson.databind

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


    ObjectMapper mapper = dataFormat.getConfiguredObjectMapper();
    JsonFactory factory = mapper.getFactory();

    try {
      JsonGenerator generator = factory.createGenerator(outputStream);
      mapper.writeTree(generator, jsonNode);
    } catch (IOException e) {
      throw LOG.unableToWriteJsonNode(e);
    }

    return outputStream;
View Full Code Here


    ObjectMapper mapper = dataFormat.getConfiguredObjectMapper();
    JsonFactory factory = mapper.getFactory();

    try {
      JsonGenerator generator = factory.createGenerator(writer);
      mapper.writeTree(generator, jsonNode);
    } catch (IOException e) {
      throw LOG.unableToWriteJsonNode(e);
    }

    return writer;
View Full Code Here

        try {
            JsonFactory fac = new JsonFactory();
            JsonGenerator gen = fac.createJsonGenerator(out);

            // Now write:
            mapper.writeTree(gen, json);
            gen.flush();
            gen.close();
            return out.toString();
        }
        catch(Exception e) {
View Full Code Here

          TreeNode tree = (TreeNode)object;
          JsonFactory jfactory = new JsonFactory();
          ByteArrayOutputStream buffer = new ByteArrayOutputStream();
          JsonGenerator generator = jfactory.createGenerator(buffer);
          ObjectMapper mapper = new ObjectMapper();
          mapper.writeTree(generator, tree);
          data = buffer.toByteArray();
        }
        catch (IOException e) {
          throw new UnsupportedOperationException("handle me gracefully", e);
        }
View Full Code Here

        try {
            String tweetArray = CharStreams.toString(reader);
            ArrayNode parsed = (ArrayNode)om.readTree(tweetArray);
            for (JsonNode tweet : parsed) {
                StringWriter sw = new StringWriter();
                om.writeTree(factory.createGenerator(sw), tweet);
                b.add(sw.toString());
            }
            sampleTweet = Iterators.cycle(b.build());
        } finally {
            reader.close();
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.