Examples of writeTree()


Examples of org.codehaus.jackson.JsonGenerator.writeTree()

      StringWriter out = new StringWriter();
      JsonGenerator jsonGenerator = mapper.getJsonFactory().createJsonGenerator( out );

      jsonGenerator.useDefaultPrettyPrinter();
      jsonGenerator.writeTree( tree );

      return out.toString();
    } catch ( Exception ignore ) {
      //Do not format if it is not possible...
      return String.valueOf( unformated );
View Full Code Here

Examples of org.codehaus.jackson.JsonGenerator.writeTree()

      StringWriter out = new StringWriter();
      JsonGenerator jsonGenerator = mapper.getJsonFactory().createJsonGenerator( out );

      jsonGenerator.useDefaultPrettyPrinter();
      jsonGenerator.writeTree( tree );

      return out.toString();
    } catch ( Exception ignore ) {
      //Do not format if it is not possible...
      return String.valueOf( unformated );
View Full Code Here

Examples of org.codehaus.jackson.JsonGenerator.writeTree()

        try {
            JsonFactory jsonFactory = getJsonFactory();
            StringWriter sw = new StringWriter();
            JsonGenerator generator = jsonFactory.createJsonGenerator(sw);
            JsonNode node = parser.readValueAs(JsonNode.class);
            generator.writeTree(node);
            return sw.toString();
        } catch (IOException e) {
            throw new IllegalArgumentException(e);
        }
    }
View Full Code Here

Examples of org.codehaus.jackson.JsonGenerator.writeTree()

    public static void write(JsonNode node, OutputStream out) {
        try {
            JsonFactory jsonFactory = getJsonFactory();
            JsonGenerator generator = jsonFactory.createJsonGenerator(out, JsonEncoding.UTF8);
            generator.writeTree(node);
        } catch (IOException e) {
            throw new IllegalArgumentException(e);
        }
    }
View Full Code Here

Examples of org.codehaus.jackson.JsonGenerator.writeTree()

    public static void write(JsonParser parser, OutputStream out) {
        try {
            JsonFactory jsonFactory = getJsonFactory();
            JsonGenerator generator = jsonFactory.createJsonGenerator(out, JsonEncoding.UTF8);
            JsonNode node = parser.readValueAs(JsonNode.class);
            generator.writeTree(node);
        } catch (IOException e) {
            throw new IllegalArgumentException(e);
        }
    }
View Full Code Here

Examples of org.codehaus.jackson.JsonGenerator.writeTree()

        JsonFactory jsonFactory = mapper.getJsonFactory();
        JsonGenerator jg = jsonFactory.createJsonGenerator(new OutputStreamWriter(out, charset));
        jg.useDefaultPrettyPrinter();
        jg.writeStartObject();
        jg.writeArrayFieldStart("spans");
        jg.writeTree(writeSpan(at));
        for(Iterator<Span> it = at.getEnclosed(EnumSet.allOf(SpanTypeEnum.class));it.hasNext();){
            jg.writeTree(writeSpan(it.next()));
        }
        jg.writeEndArray();
        jg.writeEndObject();
View Full Code Here

Examples of org.codehaus.jackson.JsonGenerator.writeTree()

        jg.useDefaultPrettyPrinter();
        jg.writeStartObject();
        jg.writeArrayFieldStart("spans");
        jg.writeTree(writeSpan(at));
        for(Iterator<Span> it = at.getEnclosed(EnumSet.allOf(SpanTypeEnum.class));it.hasNext();){
            jg.writeTree(writeSpan(it.next()));
        }
        jg.writeEndArray();
        jg.writeEndObject();
        jg.close();
    }
View Full Code Here

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

    try {
      JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(stringWriter);
      ObjectNode objectNode = objectMapper.readValue(json, ObjectNode.class);
      objectNode.put(fieldName, id);
      objectMapper.writeTree(jsonGenerator, objectNode);
      jsonGenerator.flush();
      jsonGenerator.close();
      return stringWriter.toString();
    } catch (Exception e) {
      log.error(e);
View Full Code Here

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

      JsonParser jsonParser = jsonFactory.createJsonParser(new StringReader(json));
      JsonNode jsonNode = objectMapper.readTree(jsonParser);
      JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(stringWriter);
      jsonGenerator.useDefaultPrettyPrinter();

      objectMapper.writeTree(jsonGenerator, jsonNode);

      jsonGenerator.flush();
      jsonGenerator.close();

      /*
 
View Full Code Here

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

            // Create pretty printer:
            JsonGenerator gen = fac.createJsonGenerator(out);
            gen.useDefaultPrettyPrinter();

            // Now write:
            mapper.writeTree(gen, node);
           
            gen.flush();
            gen.close();
            return out.toString();
        }
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.