Example usage for com.fasterxml.jackson.core JsonGenerator writeObjectFieldStart

List of usage examples for com.fasterxml.jackson.core JsonGenerator writeObjectFieldStart

Introduction

In this page you can find the example usage for com.fasterxml.jackson.core JsonGenerator writeObjectFieldStart.

Prototype

public final void writeObjectFieldStart(String fieldName) throws IOException, JsonGenerationException 

Source Link

Document

Convenience method for outputting a field entry ("member") (that will contain a JSON Object value), and the START_OBJECT marker.

Usage

From source file:net.opentsdb.meta.Annotation.java

/**
 * Serializes the object in a uniform matter for storage. Needed for 
 * successful CAS calls//from w w w. j  a va 2 s .c  o m
 * @return The serialized object as a byte array
 */
private byte[] getStorageJSON() {
    // TODO - precalculate size
    final ByteArrayOutputStream output = new ByteArrayOutputStream();
    try {
        final JsonGenerator json = JSON.getFactory().createGenerator(output);
        json.writeStartObject();
        if (tsuid != null && !tsuid.isEmpty()) {
            json.writeStringField("tsuid", tsuid);
        }
        json.writeNumberField("startTime", start_time);
        json.writeNumberField("endTime", end_time);
        json.writeStringField("description", description);
        json.writeStringField("notes", notes);
        if (custom == null) {
            json.writeNullField("custom");
        } else {
            json.writeObjectFieldStart("custom");
            for (Map.Entry<String, String> entry : custom.entrySet()) {
                json.writeStringField(entry.getKey(), entry.getValue());
            }
            json.writeEndObject();
        }

        json.writeEndObject();
        json.close();
        return output.toByteArray();
    } catch (IOException e) {
        throw new RuntimeException("Unable to serialize Annotation", e);
    }
}

From source file:com.attribyte.essem.es.SearchRequest.java

@Override
public void generate(final JsonGenerator generator) throws IOException {
    generator.writeStartObject();//from  w w  w . j  a va2 s.  c om
    {
        if (!retrieveSource)
            generator.writeBooleanField("_source", false);
        if (explain)
            generator.writeBooleanField("explain", true);
        if (!disablePaging) {
            generator.writeNumberField("from", start);
            generator.writeNumberField("size", limit);
        }
        if (timeoutSeconds > 0) {
            generator.writeNumberField("timeout", timeoutSeconds * 1000);
        }
        if (sortField != null)
            generateSort(generator);
        if (fields != null && fields.size() > 0)
            generateFields(generator);
        if (query != null) {
            generator.writeFieldName("query");
            query.generate(generator);
        }

        if (sort != null) {
            sort.generate(generator);
        }

        if (aggregations != null && aggregations.size() > 0) {
            generator.writeObjectFieldStart(Aggregation.AGGREGATION_OBJECT_NAME);
            for (Aggregation aggregation : aggregations) {
                aggregation.generate(generator);
            }
            generator.writeEndObject();
        }
    }
    generator.writeEndObject();
}

From source file:com.proofpoint.event.client.EventJsonSerializer.java

@Override
public void serialize(T event, JsonGenerator jsonGenerator, SerializerProvider provider) throws IOException {
    jsonGenerator.writeStartObject();//from w w  w  .  ja va  2s. c om

    jsonGenerator.writeStringField("type", eventTypeMetadata.getTypeName());

    if (eventTypeMetadata.getUuidField() != null) {
        eventTypeMetadata.getUuidField().writeField(jsonGenerator, event);
    } else {
        jsonGenerator.writeStringField("uuid", UUID.randomUUID().toString());
    }

    if (eventTypeMetadata.getHostField() != null) {
        eventTypeMetadata.getHostField().writeField(jsonGenerator, event);
    } else {
        jsonGenerator.writeStringField("host", hostName);
    }

    if (eventTypeMetadata.getTimestampField() != null) {
        eventTypeMetadata.getTimestampField().writeField(jsonGenerator, event);
    } else {
        jsonGenerator.writeFieldName("timestamp");
        EventDataType.DATETIME.writeFieldValue(jsonGenerator, new DateTime());
    }

    if (eventTypeMetadata.getTraceTokenField() != null) {
        eventTypeMetadata.getTraceTokenField().writeField(jsonGenerator, event);
    } else if (token != null) {
        jsonGenerator.writeFieldName("traceToken");
        EventDataType.STRING.writeFieldValue(jsonGenerator, token);
    }

    jsonGenerator.writeObjectFieldStart("data");
    for (EventFieldMetadata field : eventTypeMetadata.getFields()) {
        field.writeField(jsonGenerator, event);
    }
    jsonGenerator.writeEndObject();

    jsonGenerator.writeEndObject();
    jsonGenerator.flush();
}

From source file:org.jmxtrans.embedded.output.CopperEggWriter.java

public void cue_serialize(@Nonnull Iterable<QueryResult> counters, @Nonnull OutputStream out)
        throws IOException {
    int first = 0;
    long time = 0;
    String myID = null;/*from  w ww .j a  va  2 s  .  c  o  m*/
    JsonGenerator g = jsonFactory.createGenerator(out, JsonEncoding.UTF8);

    for (QueryResult counter : counters) {
        if (0 == first) {
            time = counter.getEpoch(TimeUnit.SECONDS);
            myID = counter.getType();
            first = 1;
            g.writeStartObject();
            g.writeStringField("identifier", myID);
            g.writeNumberField("timestamp", time);
            g.writeObjectFieldStart("values");
        }
        if (counter.getValue() instanceof Integer) {
            g.writeNumberField(counter.getName(), (Integer) counter.getValue());
        } else if (counter.getValue() instanceof Long) {
            g.writeNumberField(counter.getName(), (Long) counter.getValue());
        } else if (counter.getValue() instanceof Float) {
            g.writeNumberField(counter.getName(), (Float) counter.getValue());
        } else if (counter.getValue() instanceof Double) {
            g.writeNumberField(counter.getName(), (Double) counter.getValue());
        }
    }
    g.writeEndObject();
    g.writeEndObject();
    g.flush();
    g.close();
}

From source file:io.mesosphere.mesos.frameworks.cassandra.scheduler.api.ConfigController.java

/**
 * Returns the configuration as JSON.//  ww w.  j  av  a  2  s  .  c  o  m
 *
 *     Example: <pre>{@code {
 * "frameworkName" : "cassandra",
 * "frameworkId" : "20150318-143436-16777343-5050-5621-0000",
 * "defaultConfigRole" : {
 *     "cassandraVersion" : "2.1.4",
 *     "targetNodeCount" : 2,
 *     "seedNodeCount" : 1,
 *     "diskMb" : 2048,
 *     "cpuCores" : 2.0,
 *     "memJavaHeapMb" : 1024,
 *     "memAssumeOffHeapMb" : 1024,
 *     "memMb" : 2048,
 *     "taskEnv" : null
 * },
 * "nativePort" : 9042,
 * "rpcPort" : 9160,
 * "storagePort" : 7000,
 * "sslStoragePort" : 7001,
 * "seeds" : [ "127.0.0.1" ],
 * "healthCheckIntervalSeconds" : 10,
 * "bootstrapGraceTimeSeconds" : 0,
 * "currentClusterTask" : null,
 * "lastRepair" : null,
 * "lastCleanup" : null,
 * "nextPossibleServerLaunchTimestamp" : 1426685858805
 * }}</pre>
 */
@GET
public Response config() {
    return JaxRsUtils.buildStreamingResponse(factory, new StreamingJsonResponse() {
        @Override
        public void write(final JsonGenerator json) throws IOException {

            final PersistedCassandraFrameworkConfiguration configuration = cluster.getConfiguration();
            final CassandraFrameworkProtos.CassandraFrameworkConfiguration config = configuration.get();

            json.writeStringField("frameworkName", config.getFrameworkName());
            json.writeStringField("frameworkId", config.getFrameworkId());
            json.writeStringField("clusterName", config.getClusterName());
            json.writeNumberField("targetNumberOfNodes", config.getTargetNumberOfNodes());
            json.writeNumberField("targetNumberOfSeeds", config.getTargetNumberOfSeeds());

            final NodeCounts nodeCounts = cluster.getClusterState().nodeCounts();
            json.writeNumberField("currentNumberOfNodes", nodeCounts.getNodeCount());
            json.writeNumberField("currentNumberOfSeeds", nodeCounts.getSeedCount());
            json.writeNumberField("nodesToAcquire",
                    CassandraCluster.numberOfNodesToAcquire(nodeCounts, configuration));
            json.writeNumberField("seedsToAcquire",
                    CassandraCluster.numberOfSeedsToAcquire(nodeCounts, configuration));

            final CassandraFrameworkProtos.CassandraConfigRole configRole = config.getDefaultConfigRole();
            json.writeObjectFieldStart("defaultConfigRole");
            JaxRsUtils.writeConfigRole(json, configRole);
            json.writeEndObject();

            json.writeNumberField("nativePort",
                    CassandraCluster.getPortMapping(config, CassandraCluster.PORT_NATIVE));
            json.writeNumberField("rpcPort",
                    CassandraCluster.getPortMapping(config, CassandraCluster.PORT_RPC));
            json.writeNumberField("storagePort",
                    CassandraCluster.getPortMapping(config, CassandraCluster.PORT_STORAGE));
            json.writeNumberField("sslStoragePort",
                    CassandraCluster.getPortMapping(config, CassandraCluster.PORT_STORAGE_SSL));

            JaxRsUtils.writeSeedIps(cluster, json);

            json.writeNumberField("healthCheckIntervalSeconds", config.getHealthCheckIntervalSeconds());
            json.writeNumberField("bootstrapGraceTimeSeconds", config.getBootstrapGraceTimeSeconds());

            final CassandraFrameworkProtos.ClusterJobStatus currentTask = cluster.getCurrentClusterJob();
            JaxRsUtils.writeClusterJob(cluster, json, "currentClusterTask", currentTask);

            final CassandraFrameworkProtos.ClusterJobStatus lastRepair = cluster
                    .getLastClusterJob(CassandraFrameworkProtos.ClusterJobType.REPAIR);
            JaxRsUtils.writeClusterJob(cluster, json, "lastRepair", lastRepair);

            final CassandraFrameworkProtos.ClusterJobStatus lastCleanup = cluster
                    .getLastClusterJob(CassandraFrameworkProtos.ClusterJobType.CLEANUP);
            JaxRsUtils.writeClusterJob(cluster, json, "lastCleanup", lastCleanup);

            json.writeNumberField("nextPossibleServerLaunchTimestamp",
                    cluster.nextPossibleServerLaunchTimestamp());

        }
    });
}

From source file:de.escalon.hypermedia.spring.hydra.PagedResourcesSerializer.java

protected void serializeContext(Object bean, JsonGenerator jgen, SerializerProvider serializerProvider,
        Deque<LdContext> contextStack) throws IOException {
    // TODO: this code is duplicated from JacksonHydraSerializer, see there for considerations
    if (proxyUnwrapper != null) {
        bean = proxyUnwrapper.unwrapProxy(bean);
    }/* w  w w  . ja v a2 s  .c o m*/
    MixinSource mixinSource = new JacksonMixinSource(serializerProvider.getConfig());
    final Class<?> mixInClass = mixinSource.findMixInClassFor(bean.getClass());

    final LdContext parentContext = contextStack.peek();
    LdContext currentContext = new LdContext(parentContext,
            ldContextFactory.getVocab(mixinSource, bean, mixInClass),
            ldContextFactory.getTerms(mixinSource, bean, mixInClass));
    contextStack.push(currentContext);
    // check if we need to write a context for the current bean at all
    // If it is in the same vocab: no context
    // If the terms are already defined in the context: no context
    boolean mustWriteContext;
    if (parentContext == null || !parentContext.contains(currentContext)) {
        mustWriteContext = true;
    } else {
        mustWriteContext = false;
    }

    if (mustWriteContext) {
        // begin context
        // default context: schema.org vocab or vocab package annotation
        jgen.writeObjectFieldStart("@context");
        // do not repeat vocab if already defined in current context
        if (parentContext == null || parentContext.vocab == null
                || (currentContext.vocab != null && !currentContext.vocab.equals(parentContext.vocab))) {
            jgen.writeStringField(JsonLdKeywords.AT_VOCAB, currentContext.vocab);
        }

        for (Map.Entry<String, Object> termEntry : currentContext.terms.entrySet()) {
            if (termEntry.getValue() instanceof String) {
                jgen.writeStringField(termEntry.getKey(), termEntry.getValue().toString());
            } else {
                jgen.writeObjectField(termEntry.getKey(), termEntry.getValue());
            }
        }
        jgen.writeEndObject();
        // end context
    }
}

From source file:net.opentsdb.meta.TSMeta.java

/**
 * Formats the JSON output for writing to storage. It drops objects we don't
 * need or want to store (such as the UIDMeta objects or the total dps) to
 * save space. It also serializes in order so that we can make a proper CAS
 * call. Otherwise the POJO serializer may place the fields in any order
 * and CAS calls would fail all the time.
 * @return A byte array to write to storage
 *//*from   w  w  w.  java  2 s . c om*/
private byte[] getStorageJSON() {
    // 256 bytes is a good starting value, assumes default info
    final ByteArrayOutputStream output = new ByteArrayOutputStream(256);
    try {
        final JsonGenerator json = JSON.getFactory().createGenerator(output);
        json.writeStartObject();
        json.writeStringField("tsuid", tsuid);
        json.writeStringField("displayName", display_name);
        json.writeStringField("description", description);
        json.writeStringField("notes", notes);
        json.writeNumberField("created", created);
        if (custom == null) {
            json.writeNullField("custom");
        } else {
            json.writeObjectFieldStart("custom");
            for (Map.Entry<String, String> entry : custom.entrySet()) {
                json.writeStringField(entry.getKey(), entry.getValue());
            }
            json.writeEndObject();
        }
        json.writeStringField("units", units);
        json.writeStringField("dataType", data_type);
        json.writeNumberField("retention", retention);
        json.writeNumberField("max", max);
        json.writeNumberField("min", min);

        json.writeEndObject();
        json.close();
        return output.toByteArray();
    } catch (IOException e) {
        throw new RuntimeException("Unable to serialize TSMeta", e);
    }
}

From source file:de.escalon.hypermedia.spring.hydra.LinkListSerializer.java

private void writeActionDescriptors(JsonGenerator jgen, String currentVocab,
        List<ActionDescriptor> actionDescriptors) throws IOException, IntrospectionException {
    for (ActionDescriptor actionDescriptor : actionDescriptors) {
        if ("GET".equals(actionDescriptor.getHttpMethod())) {
            continue;
        }/*  w w  w .ja v  a  2 s  . c o  m*/

        jgen.writeStartObject(); // begin a hydra:Operation

        final String semanticActionType = actionDescriptor.getSemanticActionType();
        if (semanticActionType != null) {
            jgen.writeStringField("@type", semanticActionType);
        }
        jgen.writeStringField("hydra:method", actionDescriptor.getHttpMethod());

        final ActionInputParameter requestBodyInputParameter = actionDescriptor.getRequestBody();
        if (requestBodyInputParameter != null) {

            jgen.writeObjectFieldStart("hydra:expects"); // begin hydra:expects

            final Class<?> clazz = requestBodyInputParameter.getParameterType();
            final Expose classExpose = clazz.getAnnotation(Expose.class);
            final String typeName;
            if (classExpose != null) {
                typeName = classExpose.value();
            } else {
                typeName = requestBodyInputParameter.getParameterType().getSimpleName();
            }
            jgen.writeStringField("@type", typeName);

            jgen.writeArrayFieldStart("hydra:supportedProperty"); // begin hydra:supportedProperty
            // TODO check need for allRootParameters and requestBodyInputParameter here:
            recurseSupportedProperties(jgen, currentVocab, clazz, actionDescriptor, requestBodyInputParameter,
                    requestBodyInputParameter.getValue(), "");
            jgen.writeEndArray(); // end hydra:supportedProperty

            jgen.writeEndObject(); // end hydra:expects
        }

        jgen.writeEndObject(); // end hydra:Operation
    }
}

From source file:com.predic8.membrane.core.interceptor.administration.AdminRESTInterceptor.java

@Mapping("/admin/rest/proxies(/?\\?.*)?")
public Response getProxies(final QueryParameter params, String relativeRootPath) throws Exception {
    final List<AbstractServiceProxy> proxies = getServiceProxies();

    if ("order".equals(params.getString("sort"))) {
        if (params.getString("order", "asc").equals("desc"))
            Collections.reverse(proxies);
    } else {//w ww  .  j ava2s  .c  o m
        Collections.sort(proxies, ComparatorFactory.getAbstractServiceProxyComparator(
                params.getString("sort", "name"), params.getString("order", "asc")));
    }

    final int offset = params.getInt("offset", 0);
    int max = params.getInt("max", proxies.size());

    final List<AbstractServiceProxy> paginated = proxies.subList(offset,
            Math.min(offset + max, proxies.size()));

    return json(new JSONContent() {
        public void write(JsonGenerator gen) throws Exception {
            gen.writeStartObject();
            gen.writeArrayFieldStart("proxies");
            int i = offset;
            if (params.getString("order", "asc").equals("desc"))
                i = proxies.size() - i + 1;
            for (AbstractServiceProxy p : paginated) {
                gen.writeStartObject();
                gen.writeNumberField("order", i += params.getString("order", "asc").equals("desc") ? -1 : 1);
                gen.writeStringField("name", p.toString());
                gen.writeBooleanField("active", p.isActive());
                if (!p.isActive())
                    gen.writeStringField("error", p.getErrorState());
                gen.writeNumberField("listenPort", p.getKey().getPort());
                gen.writeStringField("virtualHost", p.getKey().getHost());
                gen.writeStringField("method", p.getKey().getMethod());
                gen.writeStringField("path", p.getKey().getPath());
                gen.writeStringField("targetHost", p.getTargetHost());
                gen.writeNumberField("targetPort", p.getTargetPort());
                gen.writeNumberField("count", p.getCount());
                gen.writeObjectFieldStart("actions");
                if (!isReadOnly()) {
                    gen.writeStringField("delete", "/admin/service-proxy/delete?name="
                            + URLEncoder.encode(RuleUtil.getRuleIdentifier(p), "UTF-8"));
                }
                if (!p.isActive())
                    gen.writeStringField("start", "/admin/service-proxy/start?name="
                            + URLEncoder.encode(RuleUtil.getRuleIdentifier(p), "UTF-8"));
                gen.writeEndObject();
                gen.writeEndObject();
            }
            gen.writeEndArray();
            gen.writeNumberField("total", proxies.size());
            gen.writeEndObject();
        }
    });
}

From source file:io.mesosphere.mesos.frameworks.cassandra.scheduler.api.NodeController.java

/**
 * Retrieve a list of all nodes including their status.
 *
 *     <pre>{@code {/*from www  .  j  a v  a 2  s .c om*/
 * "replaceNodes" : [ ],
 * "nodesToAcquire" : 0,
 * "nodes" : [ {
 *     "tasks" : {
 *         "METADATA" : {
 *             "cpuCores" : 0.1,
 *             "diskMb" : 16,
 *             "memMb" : 16,
 *             "taskId" : "cassandra.node.0.executor"
 *         },
 *         "SERVER" : {
 *             "cpuCores" : 2.0,
 *             "diskMb" : 2048,
 *             "memMb" : 2048,
 *             "taskId" : "cassandra.node.0.executor.server"
 *         }
 *     },
 *     "executorId" : "cassandra.node.0.executor",
 *     "ip" : "127.0.0.2",
 *     "hostname" : "127.0.0.2",
 *     "targetRunState" : "RUN",
 *     "jmxPort" : 64112,
 *     "seedNode" : true,
 *     "cassandraDaemonPid" : 6104,
 *     "lastHealthCheck" : 1426686217128,
 *     "healthCheckDetails" : {
 *         "healthy" : true,
 *         "msg" : "",
 *         "version" : "2.1.4",
 *         "operationMode" : "NORMAL",
 *         "clusterName" : "cassandra",
 *         "dataCenter" : "DC1",
 *         "rack" : "RAC1",
 *         "endpoint" : "127.0.0.2",
 *         "hostId" : "4207396e-6aa0-432e-97d9-1a4df3c1057f",
 *         "joined" : true,
 *         "gossipInitialized" : true,
 *         "gossipRunning" : true,
 *         "nativeTransportRunning" : true,
 *         "rpcServerRunning" : true,
 *         "tokenCount" : 256,
 *         "uptimeMillis" : 29072
 *     }
 * }, {
 *     "tasks" : {
 *     "METADATA" : {
 *         "cpuCores" : 0.1,
 *         "diskMb" : 16,
 *         "memMb" : 16,
 *         "taskId" : "cassandra.node.1.executor"
 *     },
 *     "SERVER" : {
 *         "cpuCores" : 2.0,
 *         "diskMb" : 2048,
 *         "memMb" : 2048,
 *         "taskId" : "cassandra.node.1.executor.server"
 *     }
 *     },
 *     "executorId" : "cassandra.node.1.executor",
 *     "ip" : "127.0.0.1",
 *     "hostname" : "localhost",
 *     "targetRunState" : "RUN",
 *     "jmxPort" : 64113,
 *     "seedNode" : false,
 *     "cassandraDaemonPid" : 6127,
 *     "lastHealthCheck" : 1426686217095,
 *     "healthCheckDetails" : {
 *         "healthy" : true,
 *         "msg" : "",
 *         "version" : "2.1.4",
 *         "operationMode" : "JOINING",
 *         "clusterName" : "cassandra",
 *         "dataCenter" : "",
 *         "rack" : "",
 *         "endpoint" : "",
 *         "hostId" : "",
 *         "joined" : true,
 *         "gossipInitialized" : true,
 *         "gossipRunning" : true,
 *         "nativeTransportRunning" : false,
 *         "rpcServerRunning" : false,
 *         "tokenCount" : 0,
 *         "uptimeMillis" : 16936
 *     }
 * } ]
 * }}</pre>
 */
@GET
@Path("/all")
public Response nodes() {
    return JaxRsUtils.buildStreamingResponse(factory, new StreamingJsonResponse() {
        @Override
        public void write(final JsonGenerator json) throws IOException {
            final CassandraFrameworkProtos.CassandraClusterState clusterState = cluster.getClusterState().get();

            json.writeArrayFieldStart("replaceNodes");
            for (final String ip : clusterState.getReplaceNodeIpsList()) {
                json.writeString(ip);
            }
            json.writeEndArray();

            final NodeCounts nodeCounts = cluster.getClusterState().nodeCounts();
            json.writeNumberField("nodesToAcquire",
                    CassandraCluster.numberOfNodesToAcquire(nodeCounts, cluster.getConfiguration()));

            json.writeArrayFieldStart("nodes");
            for (final CassandraFrameworkProtos.CassandraNode cassandraNode : clusterState.getNodesList()) {
                json.writeStartObject();

                if (cassandraNode.hasReplacementForIp()) {
                    json.writeStringField("replacementForIp", cassandraNode.getReplacementForIp());
                }

                json.writeObjectFieldStart("tasks");
                for (final CassandraFrameworkProtos.CassandraNodeTask cassandraNodeTask : cassandraNode
                        .getTasksList()) {
                    JaxRsUtils.writeTask(json, cassandraNodeTask);
                }
                json.writeEndObject();
                // TODO                cassandraNode.getDataVolumesList();

                if (!cassandraNode.hasCassandraNodeExecutor()) {
                    json.writeNullField("executorId");
                    json.writeNullField("workdir");
                } else {
                    json.writeStringField("executorId",
                            cassandraNode.getCassandraNodeExecutor().getExecutorId());
                    final CassandraFrameworkProtos.ExecutorMetadata executorMetadata = cluster
                            .metadataForExecutor(cassandraNode.getCassandraNodeExecutor().getExecutorId());
                    if (executorMetadata != null) {
                        json.writeStringField("workdir", executorMetadata.getWorkdir());
                    } else {
                        json.writeNullField("workdir");
                    }
                }
                json.writeStringField("ip", cassandraNode.getIp());
                json.writeStringField("hostname", cassandraNode.getHostname());
                json.writeStringField("targetRunState", cassandraNode.getTargetRunState().name());
                json.writeNumberField("jmxPort", cassandraNode.getJmxConnect().getJmxPort());
                json.writeBooleanField("seedNode", cassandraNode.getSeed());

                CassandraFrameworkProtos.RackDc rackDc = cassandraNode.getRackDc();
                json.writeObjectFieldStart("rackDc");
                json.writeStringField("rack", rackDc.getRack());
                json.writeStringField("dc", rackDc.getDc());
                json.writeEndObject();

                if (!cassandraNode.hasCassandraDaemonPid()) {
                    json.writeNullField("cassandraDaemonPid");
                } else {
                    json.writeNumberField("cassandraDaemonPid", cassandraNode.getCassandraDaemonPid());
                }

                final CassandraFrameworkProtos.HealthCheckHistoryEntry lastHealthCheck = cassandraNode
                        .hasCassandraNodeExecutor()
                                ? cluster.lastHealthCheck(
                                        cassandraNode.getCassandraNodeExecutor().getExecutorId())
                                : null;

                if (lastHealthCheck != null) {
                    json.writeNumberField("lastHealthCheck", lastHealthCheck.getTimestampEnd());
                } else {
                    json.writeNullField("lastHealthCheck");
                }

                if (lastHealthCheck != null) {
                    json.writeObjectFieldStart("healthCheckDetails");

                    final CassandraFrameworkProtos.HealthCheckDetails hcd = lastHealthCheck.getDetails();

                    json.writeBooleanField("healthy", hcd.getHealthy());
                    json.writeStringField("msg", hcd.getMsg());

                    json.writeStringField("version", hcd.getInfo().getVersion());
                    json.writeStringField("operationMode", hcd.getInfo().getOperationMode());
                    json.writeStringField("clusterName", hcd.getInfo().getClusterName());
                    json.writeStringField("dataCenter", hcd.getInfo().getDataCenter());
                    json.writeStringField("rack", hcd.getInfo().getRack());
                    json.writeStringField("endpoint", hcd.getInfo().getEndpoint());
                    json.writeStringField("hostId", hcd.getInfo().getHostId());
                    json.writeBooleanField("joined", hcd.getInfo().getJoined());
                    json.writeBooleanField("gossipInitialized", hcd.getInfo().getGossipInitialized());
                    json.writeBooleanField("gossipRunning", hcd.getInfo().getGossipRunning());
                    json.writeBooleanField("nativeTransportRunning", hcd.getInfo().getNativeTransportRunning());
                    json.writeBooleanField("rpcServerRunning", hcd.getInfo().getRpcServerRunning());
                    json.writeNumberField("tokenCount", hcd.getInfo().getTokenCount());
                    json.writeNumberField("uptimeMillis", hcd.getInfo().getUptimeMillis());

                    json.writeEndObject();
                } else {
                    json.writeNullField("healthCheckDetails");
                }

                final List<CassandraFrameworkProtos.DataVolume> dataVolumes = cassandraNode
                        .getDataVolumesList();
                json.writeArrayFieldStart("dataVolumes");
                for (final CassandraFrameworkProtos.DataVolume volume : dataVolumes) {
                    json.writeStartObject();
                    json.writeStringField("path", volume.getPath());
                    if (volume.hasSizeMb()) {
                        json.writeNumberField("size", volume.getSizeMb());
                    }
                    json.writeEndObject();
                }
                json.writeEndArray();

                json.writeEndObject();
            }
            json.writeEndArray();
        }
    });
}