List of usage examples for com.fasterxml.jackson.core JsonGenerator writeObjectFieldStart
public final void writeObjectFieldStart(String fieldName) throws IOException, JsonGenerationException
From source file:com.neoteric.starter.metrics.report.elastic.ElasticsearchReporter.java
private void checkForIndexTemplate() { try {/*from w ww . ja va 2s. co m*/ HttpURLConnection connection = openConnection("/_template/metrics_template", "HEAD"); connection.disconnect(); boolean isTemplateMissing = connection.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND; // nothing there, lets create it if (isTemplateMissing) { LOGGER.debug("No metrics template found in elasticsearch. Adding..."); HttpURLConnection putTemplateConnection = openConnection("/_template/metrics_template", "PUT"); JsonGenerator json = new JsonFactory().createGenerator(putTemplateConnection.getOutputStream()); json.writeStartObject(); json.writeStringField("template", index + "*"); json.writeObjectFieldStart("mappings"); json.writeObjectFieldStart("_default_"); json.writeObjectFieldStart("_all"); json.writeBooleanField("enabled", false); json.writeEndObject(); json.writeObjectFieldStart("properties"); json.writeObjectFieldStart("name"); json.writeObjectField("type", "string"); json.writeObjectField("index", "not_analyzed"); json.writeEndObject(); json.writeEndObject(); json.writeEndObject(); json.writeEndObject(); json.writeEndObject(); json.flush(); putTemplateConnection.disconnect(); if (putTemplateConnection.getResponseCode() != HttpStatus.OK.value()) { LOGGER.error( "Error adding metrics template to elasticsearch: {}/{}" + putTemplateConnection.getResponseCode(), putTemplateConnection.getResponseMessage()); } } checkedForIndexTemplate = true; } catch (IOException e) { LOGGER.error("Error when checking/adding metrics template to elasticsearch", e); } }
From source file:org.springframework.cloud.netflix.hystrix.amqp.HystrixStreamTask.java
@Scheduled(fixedRateString = "${hystrix.stream.amqp.gatherRate:500}") public void gatherMetrics() { try {/*from w w w .j a v a 2 s. c om*/ // command metrics Collection<HystrixCommandMetrics> instances = HystrixCommandMetrics.getInstances(); if (!instances.isEmpty()) { log.trace("gathering metrics size: " + instances.size()); } ServiceInstance localService = this.discoveryClient.getLocalServiceInstance(); for (HystrixCommandMetrics commandMetrics : instances) { HystrixCommandKey key = commandMetrics.getCommandKey(); HystrixCircuitBreaker circuitBreaker = HystrixCircuitBreaker.Factory.getInstance(key); StringWriter jsonString = new StringWriter(); JsonGenerator json = this.jsonFactory.createGenerator(jsonString); json.writeStartObject(); addServiceData(json, localService); json.writeObjectFieldStart("data"); json.writeStringField("type", "HystrixCommand"); String name = key.name(); if (this.properties.isPrefixMetricName()) { name = localService.getServiceId() + "." + name; } json.writeStringField("name", name); json.writeStringField("group", commandMetrics.getCommandGroup().name()); json.writeNumberField("currentTime", System.currentTimeMillis()); // circuit breaker if (circuitBreaker == null) { // circuit breaker is disabled and thus never open json.writeBooleanField("isCircuitBreakerOpen", false); } else { json.writeBooleanField("isCircuitBreakerOpen", circuitBreaker.isOpen()); } HystrixCommandMetrics.HealthCounts healthCounts = commandMetrics.getHealthCounts(); json.writeNumberField("errorPercentage", healthCounts.getErrorPercentage()); json.writeNumberField("errorCount", healthCounts.getErrorCount()); json.writeNumberField("requestCount", healthCounts.getTotalRequests()); // rolling counters json.writeNumberField("rollingCountCollapsedRequests", commandMetrics.getRollingCount(HystrixRollingNumberEvent.COLLAPSED)); json.writeNumberField("rollingCountExceptionsThrown", commandMetrics.getRollingCount(HystrixRollingNumberEvent.EXCEPTION_THROWN)); json.writeNumberField("rollingCountFailure", commandMetrics.getRollingCount(HystrixRollingNumberEvent.FAILURE)); json.writeNumberField("rollingCountFallbackFailure", commandMetrics.getRollingCount(HystrixRollingNumberEvent.FALLBACK_FAILURE)); json.writeNumberField("rollingCountFallbackRejection", commandMetrics.getRollingCount(HystrixRollingNumberEvent.FALLBACK_REJECTION)); json.writeNumberField("rollingCountFallbackSuccess", commandMetrics.getRollingCount(HystrixRollingNumberEvent.FALLBACK_SUCCESS)); json.writeNumberField("rollingCountResponsesFromCache", commandMetrics.getRollingCount(HystrixRollingNumberEvent.RESPONSE_FROM_CACHE)); json.writeNumberField("rollingCountSemaphoreRejected", commandMetrics.getRollingCount(HystrixRollingNumberEvent.SEMAPHORE_REJECTED)); json.writeNumberField("rollingCountShortCircuited", commandMetrics.getRollingCount(HystrixRollingNumberEvent.SHORT_CIRCUITED)); json.writeNumberField("rollingCountSuccess", commandMetrics.getRollingCount(HystrixRollingNumberEvent.SUCCESS)); json.writeNumberField("rollingCountThreadPoolRejected", commandMetrics.getRollingCount(HystrixRollingNumberEvent.THREAD_POOL_REJECTED)); json.writeNumberField("rollingCountTimeout", commandMetrics.getRollingCount(HystrixRollingNumberEvent.TIMEOUT)); json.writeNumberField("currentConcurrentExecutionCount", commandMetrics.getCurrentConcurrentExecutionCount()); // latency percentiles json.writeNumberField("latencyExecute_mean", commandMetrics.getExecutionTimeMean()); json.writeObjectFieldStart("latencyExecute"); json.writeNumberField("0", commandMetrics.getExecutionTimePercentile(0)); json.writeNumberField("25", commandMetrics.getExecutionTimePercentile(25)); json.writeNumberField("50", commandMetrics.getExecutionTimePercentile(50)); json.writeNumberField("75", commandMetrics.getExecutionTimePercentile(75)); json.writeNumberField("90", commandMetrics.getExecutionTimePercentile(90)); json.writeNumberField("95", commandMetrics.getExecutionTimePercentile(95)); json.writeNumberField("99", commandMetrics.getExecutionTimePercentile(99)); json.writeNumberField("99.5", commandMetrics.getExecutionTimePercentile(99.5)); json.writeNumberField("100", commandMetrics.getExecutionTimePercentile(100)); json.writeEndObject(); // json.writeNumberField("latencyTotal_mean", commandMetrics.getTotalTimeMean()); json.writeObjectFieldStart("latencyTotal"); json.writeNumberField("0", commandMetrics.getTotalTimePercentile(0)); json.writeNumberField("25", commandMetrics.getTotalTimePercentile(25)); json.writeNumberField("50", commandMetrics.getTotalTimePercentile(50)); json.writeNumberField("75", commandMetrics.getTotalTimePercentile(75)); json.writeNumberField("90", commandMetrics.getTotalTimePercentile(90)); json.writeNumberField("95", commandMetrics.getTotalTimePercentile(95)); json.writeNumberField("99", commandMetrics.getTotalTimePercentile(99)); json.writeNumberField("99.5", commandMetrics.getTotalTimePercentile(99.5)); json.writeNumberField("100", commandMetrics.getTotalTimePercentile(100)); json.writeEndObject(); // property values for reporting what is actually seen by the command // rather than what was set somewhere HystrixCommandProperties commandProperties = commandMetrics.getProperties(); json.writeNumberField("propertyValue_circuitBreakerRequestVolumeThreshold", commandProperties.circuitBreakerRequestVolumeThreshold().get()); json.writeNumberField("propertyValue_circuitBreakerSleepWindowInMilliseconds", commandProperties.circuitBreakerSleepWindowInMilliseconds().get()); json.writeNumberField("propertyValue_circuitBreakerErrorThresholdPercentage", commandProperties.circuitBreakerErrorThresholdPercentage().get()); json.writeBooleanField("propertyValue_circuitBreakerForceOpen", commandProperties.circuitBreakerForceOpen().get()); json.writeBooleanField("propertyValue_circuitBreakerForceClosed", commandProperties.circuitBreakerForceClosed().get()); json.writeBooleanField("propertyValue_circuitBreakerEnabled", commandProperties.circuitBreakerEnabled().get()); json.writeStringField("propertyValue_executionIsolationStrategy", commandProperties.executionIsolationStrategy().get().name()); json.writeNumberField("propertyValue_executionIsolationThreadTimeoutInMilliseconds", commandProperties.executionIsolationThreadTimeoutInMilliseconds().get()); json.writeBooleanField("propertyValue_executionIsolationThreadInterruptOnTimeout", commandProperties.executionIsolationThreadInterruptOnTimeout().get()); json.writeStringField("propertyValue_executionIsolationThreadPoolKeyOverride", commandProperties.executionIsolationThreadPoolKeyOverride().get()); json.writeNumberField("propertyValue_executionIsolationSemaphoreMaxConcurrentRequests", commandProperties.executionIsolationSemaphoreMaxConcurrentRequests().get()); json.writeNumberField("propertyValue_fallbackIsolationSemaphoreMaxConcurrentRequests", commandProperties.fallbackIsolationSemaphoreMaxConcurrentRequests().get()); // TODO /* * The following are commented out as these rarely change and are verbose * for streaming for something people don't change. We could perhaps allow * a property or request argument to include these. */ // json.put("propertyValue_metricsRollingPercentileEnabled", // commandProperties.metricsRollingPercentileEnabled().get()); // json.put("propertyValue_metricsRollingPercentileBucketSize", // commandProperties.metricsRollingPercentileBucketSize().get()); // json.put("propertyValue_metricsRollingPercentileWindow", // commandProperties.metricsRollingPercentileWindowInMilliseconds().get()); // json.put("propertyValue_metricsRollingPercentileWindowBuckets", // commandProperties.metricsRollingPercentileWindowBuckets().get()); // json.put("propertyValue_metricsRollingStatisticalWindowBuckets", // commandProperties.metricsRollingStatisticalWindowBuckets().get()); json.writeNumberField("propertyValue_metricsRollingStatisticalWindowInMilliseconds", commandProperties.metricsRollingStatisticalWindowInMilliseconds().get()); json.writeBooleanField("propertyValue_requestCacheEnabled", commandProperties.requestCacheEnabled().get()); json.writeBooleanField("propertyValue_requestLogEnabled", commandProperties.requestLogEnabled().get()); json.writeNumberField("reportingHosts", 1); // this will get summed across // all instances in a cluster json.writeEndObject(); // end data attribute json.writeEndObject(); json.close(); // output this.jsonMetrics.add(jsonString.getBuffer().toString()); } // thread pool metrics for (HystrixThreadPoolMetrics threadPoolMetrics : HystrixThreadPoolMetrics.getInstances()) { HystrixThreadPoolKey key = threadPoolMetrics.getThreadPoolKey(); StringWriter jsonString = new StringWriter(); JsonGenerator json = this.jsonFactory.createGenerator(jsonString); json.writeStartObject(); addServiceData(json, localService); json.writeObjectFieldStart("data"); 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()); json.writeNumberField("currentCorePoolSize", threadPoolMetrics.getCurrentCorePoolSize().intValue()); json.writeNumberField("currentLargestPoolSize", threadPoolMetrics.getCurrentLargestPoolSize().intValue()); json.writeNumberField("currentMaximumPoolSize", threadPoolMetrics.getCurrentMaximumPoolSize().intValue()); json.writeNumberField("currentPoolSize", threadPoolMetrics.getCurrentPoolSize().intValue()); json.writeNumberField("currentQueueSize", threadPoolMetrics.getCurrentQueueSize().intValue()); json.writeNumberField("currentTaskCount", threadPoolMetrics.getCurrentTaskCount().longValue()); json.writeNumberField("rollingCountThreadsExecuted", threadPoolMetrics.getRollingCountThreadsExecuted()); json.writeNumberField("rollingMaxActiveThreads", threadPoolMetrics.getRollingMaxActiveThreads()); json.writeNumberField("propertyValue_queueSizeRejectionThreshold", threadPoolMetrics.getProperties().queueSizeRejectionThreshold().get()); json.writeNumberField("propertyValue_metricsRollingStatisticalWindowInMilliseconds", threadPoolMetrics.getProperties().metricsRollingStatisticalWindowInMilliseconds().get()); json.writeNumberField("reportingHosts", 1); // this will get summed across // all instances in a cluster json.writeEndObject(); // end of data object json.writeEndObject(); json.close(); // output to stream this.jsonMetrics.add(jsonString.getBuffer().toString()); } } catch (Exception ex) { log.error("Error adding metrics to queue", ex); } }
From source file:org.lambdamatic.internal.elasticsearch.codec.BooleanQuerySerializer.java
@Override public void serialize(final BooleanQuery booleanQuery, final JsonGenerator generator, final SerializerProvider serializers) throws IOException, JsonProcessingException { // if the booleanQuery does not contain other boolean queries in its elements, just write the // elements as an array if (!containsBooleanQueries(booleanQuery)) { generator.writeStartArray();/* ww w. j a va2s . c om*/ for (Query query : booleanQuery.getQueries()) { generator.writeObject(query); } generator.writeEndArray(); } else { // otherwise... generator.writeStartObject(); generator.writeObjectFieldStart("bool"); switch (booleanQuery.getType()) { case AND: // TODO: also support 'must_not' if the query is inverted. generator.writeArrayFieldStart("must"); for (Query query : booleanQuery.getQueries()) { generator.writeObject(query); } generator.writeEndArray(); // end of 'must' break; case OR: generator.writeArrayFieldStart("should"); for (Query query : booleanQuery.getQueries()) { generator.writeObject(query); } generator.writeEndArray();// end of 'should' break; default: throw new CodecException("Unexpected boolean type:" + booleanQuery.getType()); } generator.writeEndObject(); // end of 'bool' generator.writeEndObject(); // end of root } }
From source file:org.n52.tamis.core.json.serialize.processes.execute.ExecuteInputSerializer.java
private void writeAsData(JsonGenerator jsonGenerator, ExecuteInput input) throws IOException { /*// ww w . java 2 s .co m * write the input as WPS "Data" element * * expected structure looks like: * * { "Data": { "_mimeType": "text/xml", "_schema": * "http://schemas.opengis.net/gml/3.2.1/base/feature.xsd", * "__text": "value" }, * "_id": "target-variable-point" * } * * */ logger.info("Input \"{}\" is serialized as WPS \"Data\".", input); jsonGenerator.writeStartObject(); jsonGenerator.writeObjectFieldStart("Data"); jsonGenerator.writeStringField("_text", input.getValue()); /* * TODO parameters "_mimeType" and "_schema"? */ // jsonGenerator.writeStringField("_mimeType", "application/om+xml; // version=2.0"); // jsonGenerator.writeStringField("_schema", // "http://schemas.opengis.net/om/2.0/observation.xsd"); jsonGenerator.writeEndObject(); jsonGenerator.writeStringField("_id", input.getId()); jsonGenerator.writeEndObject(); }
From source file:de.escalon.hypermedia.spring.hydra.LinkListSerializer.java
private void writeIriTemplate(String rel, String href, List<String> variableNames, ActionDescriptor actionDescriptorForHttpGet, JsonGenerator jgen) throws IOException { jgen.writeObjectFieldStart(rel);/*from w w w . j a va 2s .c om*/ jgen.writeStringField("@type", "hydra:IriTemplate"); jgen.writeStringField("hydra:template", href); jgen.writeArrayFieldStart("hydra:mapping"); writeHydraVariableMapping(jgen, actionDescriptorForHttpGet, variableNames); jgen.writeEndArray(); jgen.writeEndObject(); }
From source file:org.elasticsearch.metrics.ElasticsearchReporter.java
/** * This index template is automatically applied to all indices which start with the index name * The index template simply configures the name not to be analyzed */// ww w . j a v a 2 s. co m private void checkForIndexTemplate() { try { HttpURLConnection connection = openConnection("/_template/metrics_template", "HEAD"); if (connection == null) { LOGGER.error("Could not connect to any configured elasticsearch instances: {}", Arrays.asList(hosts)); return; } connection.disconnect(); boolean isTemplateMissing = connection.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND; // nothing there, lets create it if (isTemplateMissing) { LOGGER.debug("No metrics template found in elasticsearch. Adding..."); HttpURLConnection putTemplateConnection = openConnection("/_template/metrics_template", "PUT"); if (putTemplateConnection == null) { LOGGER.error("Error adding metrics template to elasticsearch"); return; } JsonGenerator json = new JsonFactory().createGenerator(putTemplateConnection.getOutputStream()); json.writeStartObject(); json.writeStringField("template", index + "*"); json.writeObjectFieldStart("mappings"); json.writeObjectFieldStart("_default_"); json.writeObjectFieldStart("_all"); json.writeBooleanField("enabled", false); json.writeEndObject(); json.writeObjectFieldStart("properties"); json.writeObjectFieldStart("name"); json.writeObjectField("type", "string"); json.writeObjectField("index", "not_analyzed"); json.writeEndObject(); json.writeEndObject(); json.writeEndObject(); json.writeEndObject(); json.writeEndObject(); json.flush(); putTemplateConnection.disconnect(); if (putTemplateConnection.getResponseCode() != 200) { LOGGER.error( "Error adding metrics template to elasticsearch: {}/{}" + putTemplateConnection.getResponseCode(), putTemplateConnection.getResponseMessage()); } } checkedForIndexTemplate = true; } catch (IOException e) { LOGGER.error("Error when checking/adding metrics template to elasticsearch", e); } }
From source file:com.oneops.metrics.es.ElasticsearchReporter.java
/** * This index template is automatically applied to all indices which start with the index name * The index template simply configures the name not to be analyzed *//*from w ww. j av a 2 s . c o m*/ private void checkForIndexTemplate() { try { HttpURLConnection connection = openConnection("/_template/metrics_template", "HEAD"); if (connection == null) { LOGGER.error("Could not connect to any configured elasticsearch instances: {}", Arrays.asList(hosts)); return; } connection.disconnect(); boolean isTemplateMissing = connection.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND; // nothing there, lets create it if (isTemplateMissing) { LOGGER.debug("No metrics template found in elasticsearch. Adding..."); HttpURLConnection putTemplateConnection = openConnection("/_template/metrics_template", "PUT"); JsonGenerator json = new JsonFactory().createGenerator(putTemplateConnection.getOutputStream()); json.writeStartObject(); json.writeStringField("template", index + "*"); json.writeObjectFieldStart("mappings"); json.writeObjectFieldStart("_default_"); json.writeObjectFieldStart("_all"); json.writeBooleanField("enabled", false); json.writeEndObject(); json.writeObjectFieldStart("properties"); json.writeObjectFieldStart("name"); json.writeObjectField("type", "string"); json.writeObjectField("index", "not_analyzed"); json.writeEndObject(); json.writeEndObject(); json.writeEndObject(); json.writeEndObject(); json.writeEndObject(); json.flush(); putTemplateConnection.disconnect(); if (putTemplateConnection.getResponseCode() != 200) { LOGGER.error( "Error adding metrics template to elasticsearch: {}/{}" + putTemplateConnection.getResponseCode(), putTemplateConnection.getResponseMessage()); } } checkedForIndexTemplate = true; } catch (IOException e) { LOGGER.error("Error when checking/adding metrics template to elasticsearch", e); } }
From source file:de.escalon.hypermedia.spring.hydra.LinkListSerializer.java
private void writeCollectionHolder(String fieldName, TypedResource collectionHolder, JsonGenerator jgen) throws IOException { jgen.writeObjectFieldStart(fieldName); String identifyingUri = collectionHolder.getIdentifyingUri(); if (identifyingUri != null) { jgen.writeStringField(JsonLdKeywords.AT_ID, identifyingUri); }/*from ww w. j ava 2 s. c om*/ jgen.writeStringField(JsonLdKeywords.AT_TYPE, collectionHolder.getSemanticType()); jgen.writeEndObject(); }
From source file:com.netflix.hystrix.serial.SerialHystrixDashboardData.java
private static void writeCollapserMetrics(final HystrixCollapserMetrics collapserMetrics, JsonGenerator json) throws IOException { HystrixCollapserKey key = collapserMetrics.getCollapserKey(); json.writeStartObject();//w w w . ja va 2 s . c o m json.writeStringField("type", "HystrixCollapser"); json.writeStringField("name", key.name()); json.writeNumberField("currentTime", System.currentTimeMillis()); safelyWriteNumberField(json, "rollingCountRequestsBatched", new Func0<Long>() { @Override public Long call() { return collapserMetrics.getRollingCount(HystrixEventType.Collapser.ADDED_TO_BATCH); } }); safelyWriteNumberField(json, "rollingCountBatches", new Func0<Long>() { @Override public Long call() { return collapserMetrics.getRollingCount(HystrixEventType.Collapser.BATCH_EXECUTED); } }); safelyWriteNumberField(json, "rollingCountResponsesFromCache", new Func0<Long>() { @Override public Long call() { return collapserMetrics.getRollingCount(HystrixEventType.Collapser.RESPONSE_FROM_CACHE); } }); // batch size percentiles json.writeNumberField("batchSize_mean", collapserMetrics.getBatchSizeMean()); json.writeObjectFieldStart("batchSize"); json.writeNumberField("25", collapserMetrics.getBatchSizePercentile(25)); json.writeNumberField("50", collapserMetrics.getBatchSizePercentile(50)); json.writeNumberField("75", collapserMetrics.getBatchSizePercentile(75)); json.writeNumberField("90", collapserMetrics.getBatchSizePercentile(90)); json.writeNumberField("95", collapserMetrics.getBatchSizePercentile(95)); json.writeNumberField("99", collapserMetrics.getBatchSizePercentile(99)); json.writeNumberField("99.5", collapserMetrics.getBatchSizePercentile(99.5)); json.writeNumberField("100", collapserMetrics.getBatchSizePercentile(100)); json.writeEndObject(); // shard size percentiles (commented-out for now) //json.writeNumberField("shardSize_mean", collapserMetrics.getShardSizeMean()); //json.writeObjectFieldStart("shardSize"); //json.writeNumberField("25", collapserMetrics.getShardSizePercentile(25)); //json.writeNumberField("50", collapserMetrics.getShardSizePercentile(50)); //json.writeNumberField("75", collapserMetrics.getShardSizePercentile(75)); //json.writeNumberField("90", collapserMetrics.getShardSizePercentile(90)); //json.writeNumberField("95", collapserMetrics.getShardSizePercentile(95)); //json.writeNumberField("99", collapserMetrics.getShardSizePercentile(99)); //json.writeNumberField("99.5", collapserMetrics.getShardSizePercentile(99.5)); //json.writeNumberField("100", collapserMetrics.getShardSizePercentile(100)); //json.writeEndObject(); //json.writeNumberField("propertyValue_metricsRollingStatisticalWindowInMilliseconds", collapserMetrics.getProperties().metricsRollingStatisticalWindowInMilliseconds().get()); json.writeBooleanField("propertyValue_requestCacheEnabled", collapserMetrics.getProperties().requestCacheEnabled().get()); json.writeNumberField("propertyValue_maxRequestsInBatch", collapserMetrics.getProperties().maxRequestsInBatch().get()); json.writeNumberField("propertyValue_timerDelayInMilliseconds", collapserMetrics.getProperties().timerDelayInMilliseconds().get()); json.writeNumberField("reportingHosts", 1); // this will get summed across all instances in a cluster json.writeEndObject(); }
From source file:org.n52.ar.layar.LayarResponse.java
/** * /* w w w . ja v a 2s .c o m*/ * "hotspots": [{ * * "id": "test_1", * * "anchor": { "geolocation": { "lat": 52.3729, "lon": 4.93 } }, * * "text": { "title": "The Layar Office", "description": "The Location of the Layar Office", "footnote": * "Powered by Layar" }, * * "imageURL": "http:\/\/custom.layar.nl\/layarimage.jpeg", } * * ] * * See http://layar.com/documentation/browser/api/getpois-response/hotspots/ * * @param generator * @param hotspots2 * @throws IOException * @throws JsonGenerationException */ private void createHotspots(JsonGenerator generator) throws JsonGenerationException, IOException { generator.writeFieldName("hotspots"); generator.writeStartArray(); for (Hotspot poi : this.hotspots) { generator.writeStartObject(); generator.writeStringField("id", poi.id); // generator.writeFieldName("actions"); // generator.writeStartArray(); // if (layarPOI.actions != null) { // for (final LayarAction layarAction : layarPOI.actions) { // layarAction.toJSON(generator); // } // } // generator.writeEndArray(); generator.writeObjectFieldStart("anchor"); generator.writeObjectFieldStart("geolocation"); generator.writeNumberField("lat", poi.lat); generator.writeNumberField("lon", poi.lon); generator.writeNumberField("alt", poi.alt); generator.writeEndObject(); generator.writeEndObject(); // generator.writeNumberField("distance", layarPOI.distance); // generator.writeNumberField("type", layarPOI.type); // generator.writeStringField("title", layarPOI.title); generator.writeObjectFieldStart("text"); generator.writeStringField("title", poi.title); generator.writeStringField("description", poi.description); generator.writeStringField("footnote", "Service URL: ..."); generator.writeEndObject(); generator.writeStringField("attribution", poi.attribution); if (poi.imageURL != null) { generator.writeStringField("imageURL", poi.imageURL.toString()); } else { generator.writeNullField("imageURL"); } generator.writeEndObject(); } generator.writeEndArray(); }