Package com.fasterxml.jackson.core

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


  public <K, V> void serialize( @Nonnull ViewResponse<K, V, ?> viewResponse, @Nonnull JacksonSerializer<? super K> keySerializer, @Nonnull JacksonSerializer<? super V> valueSerializer, @Nonnull OutputStream out ) throws IOException {
    JsonFactory jsonFactory = JacksonSupport.getJsonFactory();
    JsonGenerator generator = jsonFactory.createJsonGenerator( out, JsonEncoding.UTF8 );

    generator.writeStartObject();

    generator.writeNumberField( PROPERTY_TOTAL_ROWS, viewResponse.getTotalRows() );
    generator.writeNumberField( PROPERTY_OFFSET, viewResponse.getOffset() );

    //Now the rows
View Full Code Here


   */
  public static String createJson( @Nonnull DesignDocument designDocument, @Nullable Revision revision ) throws IOException {
    //noinspection TypeMayBeWeakened
    StringWriter writer = new StringWriter();
    JsonGenerator generator = new JsonFactory().createJsonGenerator( writer );
    generator.writeStartObject();

    generator.writeStringField( "_id", designDocument.getId() );
    if ( revision != null ) {
      generator.writeStringField( "_rev", revision.asString() );
    }
View Full Code Here

                JsonGenerator g = mapper.getMapper().getFactory().createGenerator(writer);

                g.writeStartArray();

                for (Replacement replacement : replacements.getReplacements()) {
                    g.writeStartObject();
                    g.writeStringField("caption", replacement.name);
                    g.writeStringField("meta", replacement.type);
                    g.writeStringField("snippet", replacement.snippet);
                    g.writeEndObject();
                }
View Full Code Here

  @Override
  public String apply(HystrixThreadPoolMetrics threadPoolMetrics) throws Exception {
    HystrixThreadPoolKey key = threadPoolMetrics.getThreadPoolKey();
    StringWriter jsonString = new StringWriter();
    JsonGenerator json = jsonFactory.createGenerator(jsonString);
    json.writeStartObject();
    json.writeStringField("type", "HystrixThreadPool");
    json.writeStringField("name", key.name());
    json.writeNumberField("currentTime", System.currentTimeMillis());
    json.writeNumberField("currentActiveCount", threadPoolMetrics.getCurrentActiveCount().intValue());
    json.writeNumberField("currentCompletedTaskCount", threadPoolMetrics.getCurrentCompletedTaskCount().longValue());
View Full Code Here

    HystrixCircuitBreaker circuitBreaker = HystrixCircuitBreaker.Factory.getInstance(key);

    StringWriter jsonString = new StringWriter();
    JsonGenerator json = jsonFactory.createGenerator(jsonString);

    json.writeStartObject();
    json.writeStringField("type", "HystrixCommand");
    json.writeStringField("name", key.name());
    json.writeStringField("group", commandMetrics.getCommandGroup().name());
    json.writeNumberField("currentTime", System.currentTimeMillis());
View Full Code Here

    }

    private static String buildJsonBody(String key, String value) throws IOException {
        StringWriter stringWriter = new StringWriter();
        JsonGenerator jsonGenerator = JsonUtils.createJsonGenerator(stringWriter);
        jsonGenerator.writeStartObject();
        jsonGenerator.writeStringField(key, value);
        jsonGenerator.writeEndObject();
        jsonGenerator.flush();
        jsonGenerator.close();
        return stringWriter.toString();
View Full Code Here

            // Stringify query params as JSON.
            // TODO: Is this even a good idea? Or just keep them separate?
            try {
                StringWriter str = new StringWriter();
                JsonGenerator jg = createJsonGenerator(str);
                jg.writeStartObject();
                for (Map.Entry<String,List<String>> entry : queryParams.entrySet()) {
                    if (jsonpArgName.equals(entry.getKey()))
                        continue;
                    jg.writeFieldName(entry.getKey());
                    if (entry.getValue().size() != 1)
View Full Code Here

                } else {
                    response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
                }
                try {
                    JsonGenerator generator = jsonFactory.createGenerator(out, JsonEncoding.UTF8);
                    generator.writeStartObject();
                    for (Map.Entry<String, List<String>> entry : decoder.getParameters().entrySet()) {
                        if (entry.getValue().size() == 1) {
                            generator.writeStringField(entry.getKey(), URLDecoder.decode(entry.getValue().get(0), "UTF-8"));
                        } else {
                            generator.writeArrayFieldStart(entry.getKey());
View Full Code Here

        //         value : "something"
        //    }
        // }
        BytesStreamOutput os = new BytesStreamOutput();
        JsonGenerator gen = new JsonFactory().createGenerator(os);
        gen.writeStartObject();

        gen.writeStringField("index", "test");

        gen.writeFieldName("source");
        gen.writeStartObject();
View Full Code Here

        gen.writeStartObject();

        gen.writeStringField("index", "test");

        gen.writeFieldName("source");
        gen.writeStartObject();
        gen.writeStringField("value", "something");
        gen.writeEndObject();

        gen.writeEndObject();
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.