Package com.fasterxml.jackson.core

Examples of com.fasterxml.jackson.core.JsonGenerator


    }

    public String toString(){
        StringWriter stringWriter = new StringWriter();
        try {
            JsonGenerator jsonGenerator = new JsonFactory().createGenerator(stringWriter);
            if(solution == null) writeProblem(jsonGenerator);
            else writeSolution(jsonGenerator);
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
View Full Code Here




    public void write(File jsonFile){
        try {
            JsonGenerator jsonGenerator = new JsonFactory().createGenerator(new FileOutputStream(jsonFile), JsonEncoding.UTF8);
            if(solution == null) writeProblem(jsonGenerator);
            else writeSolution(jsonGenerator);
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
View Full Code Here

            json.writeEndObject();
        }

        @Override
        public void processGauge(MetricName name, Gauge<?> gauge, Context context) throws Exception {
            final JsonGenerator json = context.json;
            json.writeStartObject();
            {
                json.writeStringField("type", "gauge");
                json.writeObjectField("value", evaluateGauge(gauge));
            }
            json.writeEndObject();
        }
View Full Code Here

        response().setContentType("application/json");
        response().setHeader("Cache-Control", "must-revalidate,no-cache,no-store");

        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);
            }

            ServerMetrics metricProcessor = new ServerMetrics();
            writeRegularMetrics(json, classPrefix, metricProcessor);
        }
        json.writeEndObject();
        json.close();

        return ok(writer.toString());
    }
View Full Code Here

    }

    public static class ServerMetrics implements MetricProcessor<Context> {
        @Override
        public void processMeter(MetricName name, Metered meter, Context context) throws Exception {
            final JsonGenerator json = context.json;
            json.writeStartObject();
            {
                json.writeStringField("type", "meter");
                json.writeStringField("event_type", meter.eventType());
                writeMeteredFields(meter, json);
            }
            json.writeEndObject();
        }
View Full Code Here

            json.writeEndObject();
        }

        @Override
        public void processCounter(MetricName name, Counter counter, Context context) throws Exception {
            final JsonGenerator json = context.json;
            json.writeStartObject();
            {
                json.writeStringField("type", "counter");
                json.writeNumberField("count", counter.count());
            }
            json.writeEndObject();
        }
View Full Code Here

            json.writeEndObject();
        }

        @Override
        public void processHistogram(MetricName name, Histogram histogram, Context context) throws Exception {
            final JsonGenerator json = context.json;
            json.writeStartObject();
            {
                json.writeStringField("type", "histogram");
                json.writeNumberField("count", histogram.count());
                writeSummarizable(histogram, json);
                writeSampling(histogram, json);

                if (context.showFullSamples) {
                    json.writeObjectField("values", histogram.getSnapshot().getValues());
                }
            }
            json.writeEndObject();
        }
View Full Code Here

            }
        }

        @Override
        public void processTimer(MetricName name, Timer timer, Context context) throws Exception {
            final JsonGenerator json = context.json;
            json.writeStartObject();
            {
                json.writeStringField("type", "timer");
                json.writeFieldName("duration");
                json.writeStartObject();
                {
                    json.writeStringField("unit", timer.durationUnit().toString().toLowerCase());
                    writeSummarizable(timer, json);
                    writeSampling(timer, json);
                    if (context.showFullSamples) {
                        json.writeObjectField("values", timer.getSnapshot().getValues());
                    }
                }
                json.writeEndObject();

                json.writeFieldName("rate");
                json.writeStartObject();
                {
                    writeMeteredFields(timer, json);
                }
                json.writeEndObject();
            }
            json.writeEndObject();
        }
View Full Code Here

  final JsonGenerator jsonGenerator;

  public MetricToJsonVisitor(OutputStream os) throws IOException {
    JsonFactory jsonFactory = buildJsonFactory();
    JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(os);

    this.jsonGenerator = jsonGenerator;
  }
View Full Code Here

    this.jsonGenerator = jsonGenerator;
  }

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

TOP

Related Classes of com.fasterxml.jackson.core.JsonGenerator

Copyright © 2018 www.massapicom. 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.