Package org.codehaus.jackson

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


        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

        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

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

        try {
            JsonFactory jsonFactory = new JsonFactory();
            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

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

    public static void write(JsonParser parser, OutputStream out) {
        try {
            JsonFactory jsonFactory = new JsonFactory();
            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

      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

      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

    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

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.