Examples of useDefaultPrettyPrinter()


Examples of com.fasterxml.jackson.core.JsonGenerator.useDefaultPrettyPrinter()

        StringWriter writer = new StringWriter();
        JsonFactory factory = new JsonFactory(new ObjectMapper());
        final JsonGenerator json = factory.createGenerator(writer);
        if (pretty) {
            json.useDefaultPrettyPrinter();
        }
        json.writeStartObject();
        {
            if (("jvm".equals(classPrefix) || Strings.isNullOrEmpty(classPrefix))) {
                writeVmMetrics(json);
View Full Code Here

Examples of com.fasterxml.jackson.core.JsonGenerator.useDefaultPrettyPrinter()

  }

  public MetricToJsonVisitor(Writer writer) throws IOException {
    JsonFactory jsonFactory = buildJsonFactory();
    JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(writer);
    jsonGenerator.useDefaultPrettyPrinter();
    this.jsonGenerator = jsonGenerator;
  }

  private JsonFactory buildJsonFactory() {
    return new JsonFactory();
View Full Code Here

Examples of com.fasterxml.jackson.core.JsonGenerator.useDefaultPrettyPrinter()

        this.objectMapper.getJsonFactory().createJsonGenerator(outputMessage.getBody(), encoding);

    // A workaround for JsonGenerators not applying serialization features
    // https://github.com/FasterXML/jackson-databind/issues/12
    if (this.objectMapper.isEnabled(SerializationFeature.INDENT_OUTPUT)) {
      jsonGenerator.useDefaultPrettyPrinter();
    }

    try {
      if (this.prefixJson) {
        jsonGenerator.writeRaw("{} && ");
View Full Code Here

Examples of com.fasterxml.jackson.core.JsonGenerator.useDefaultPrettyPrinter()

    JsonGenerator generator = this.objectMapper.getJsonFactory().createJsonGenerator(stream, this.encoding);

    // A workaround for JsonGenerators not applying serialization features
    // https://github.com/FasterXML/jackson-databind/issues/12
    if (this.objectMapper.isEnabled(SerializationFeature.INDENT_OUTPUT)) {
      generator.useDefaultPrettyPrinter();
    }

    if (this.prefixJson) {
      generator.writeRaw("{} && ");
    }
View Full Code Here

Examples of com.fasterxml.jackson.core.JsonGenerator.useDefaultPrettyPrinter()

    public static final JsonFactory JSON_FACTORY = new JsonFactory();

    public static String domToJson(Node in) throws IOException {
        final StringWriter sw = new StringWriter(512);
        final JsonGenerator gen = JSON_FACTORY.createGenerator(sw);
        gen.useDefaultPrettyPrinter();
        gen.writeStartObject();
        domToJson(in, gen);
        gen.writeEndObject();
        gen.flush();
        sw.flush();
View Full Code Here

Examples of com.fasterxml.jackson.core.JsonGenerator.useDefaultPrettyPrinter()

    public final void writeToStream(T value, OutputStream out, boolean indent)
        throws IOException
    {
        JsonGenerator g = JsonReader.jsonFactory.createGenerator(out);
        if (indent) {
            g = g.useDefaultPrettyPrinter();
        }
        try {
            write(value, g);
        }
        finally {
View Full Code Here

Examples of com.fasterxml.jackson.core.JsonGenerator.useDefaultPrettyPrinter()

    public static final JsonFactory JSON_FACTORY = new JsonFactory();

    public static String domToJson(Node in) throws IOException {
        final StringWriter sw = new StringWriter(512);
        final JsonGenerator gen = JSON_FACTORY.createGenerator(sw);
        gen.useDefaultPrettyPrinter();
        gen.writeStartObject();
        domToJson(in, gen);
        gen.writeEndObject();
        gen.flush();
        sw.flush();
View Full Code Here

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

   */
  public String toString(boolean pretty) {
    try {
      StringWriter writer = new StringWriter();
      JsonGenerator gen = FACTORY.createJsonGenerator(writer);
      if (pretty) gen.useDefaultPrettyPrinter();
      toJson(new Names(), gen);
      gen.flush();
      return writer.toString();
    } catch (IOException e) {
      throw new AvroRuntimeException(e);
View Full Code Here

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

    Schema avroSchema = Schema.parse(schema);
    ObjectMapper mapper = new ObjectMapper();
    JsonFactory factory = new JsonFactory();
    StringWriter writer = new StringWriter();
    JsonGenerator jgen = factory.createJsonGenerator(writer);
    jgen.useDefaultPrettyPrinter();

    @SuppressWarnings("checked")
    HashMap<String,Object> schemaMap = new ObjectMapper().readValue(schema, HashMap.class);

    @SuppressWarnings("checked")
View Full Code Here

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

      ObjectMapper mapper = new ObjectMapper();
      JsonFactory factory = new JsonFactory();
      StringWriter writer = new StringWriter();
      JsonGenerator jgen = factory.createJsonGenerator(writer);
      jgen.useDefaultPrettyPrinter();
      mapper.writeValue(jgen, field);
      return writer.getBuffer().toString();
    }
    catch(Exception ex)
    {
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.