Java Code Examples for com.fasterxml.jackson.core.JsonGenerator#writeBooleanField()
The following examples show how to use
com.fasterxml.jackson.core.JsonGenerator#writeBooleanField() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CameraIOProvider.java From constellation with Apache License 2.0 | 6 votes |
/** * Add a GraphBoundingBox to an ObjectNode. * * @param node The ObjectNode to write the bounding box to. * @param label The label of the bounding box node. * @param bb The bounding box to be written. */ private static void addBoundingBox(final JsonGenerator jg, final String label, final BoundingBox bb) { try { jg.writeObjectFieldStart(label); jg.writeBooleanField("is_empty", bb.isEmpty()); if (!bb.isEmpty()) { addVector(jg, "min", bb.getMin()); addVector(jg, "max", bb.getMax()); addVector(jg, "min2", bb.getMin2()); addVector(jg, "max2", bb.getMax2()); } jg.writeEndObject(); } catch (IOException ex) { Exceptions.printStackTrace(ex); } }
Example 2
Source File: DebugTabUri.java From olingo-odata4 with Apache License 2.0 | 6 votes |
private void appendGroupByItemsJson(JsonGenerator json, final List<GroupByItem> groupByItems) throws IOException { json.writeStartArray(); for (final GroupByItem groupByItem : groupByItems) { json.writeStartObject(); if (!groupByItem.getPath().isEmpty()) { json.writeFieldName("path"); appendURIResourceParts(json, groupByItem.getPath()); } json.writeBooleanField("isRollupAll", groupByItem.isRollupAll()); if (!groupByItem.getRollup().isEmpty()) { json.writeFieldName("rollup"); appendGroupByItemsJson(json, groupByItem.getRollup()); } json.writeEndObject(); } json.writeEndArray(); }
Example 3
Source File: MCRJWTUtil.java From mycore with GNU General Public License v3.0 | 6 votes |
public static Response getJWTRenewSuccessResponse(String jwt) throws IOException { try (StringWriter sw = new StringWriter()) { JsonGenerator jsonGenerator = JSON_FACTORY.createGenerator(sw); jsonGenerator.writeStartObject(); jsonGenerator.writeBooleanField("executed", true); jsonGenerator.writeStringField("access_token", jwt); jsonGenerator.writeStringField("token_type", "Bearer"); jsonGenerator.writeEndObject(); jsonGenerator.flush(); jsonGenerator.close(); return Response.status(Response.Status.OK) .header("Authorization", "Bearer " + jwt) .entity(sw.toString()) .build(); } }
Example 4
Source File: MetadataDocumentJsonSerializer.java From olingo-odata4 with Apache License 2.0 | 6 votes |
private void appendEnumTypes(JsonGenerator json, List<EdmEnumType> enumTypes) throws SerializerException, IOException { for (EdmEnumType enumType : enumTypes) { json.writeObjectFieldStart(enumType.getName()); json.writeStringField(KIND, Kind.EnumType.name()); json.writeBooleanField(IS_FLAGS, enumType.isFlags()); json.writeStringField(UNDERLYING_TYPE, getFullQualifiedName(enumType.getUnderlyingType())); for (String memberName : enumType.getMemberNames()) { EdmMember member = enumType.getMember(memberName); if (member.getValue() != null) { json.writeStringField(memberName, member.getValue()); } appendAnnotations(json, member, memberName); } json.writeEndObject(); } }
Example 5
Source File: SchemaParser.java From iceberg with Apache License 2.0 | 6 votes |
static void toJson(Types.StructType struct, JsonGenerator generator) throws IOException { generator.writeStartObject(); generator.writeStringField(TYPE, STRUCT); generator.writeArrayFieldStart(FIELDS); for (Types.NestedField field : struct.fields()) { generator.writeStartObject(); generator.writeNumberField(ID, field.fieldId()); generator.writeStringField(NAME, field.name()); generator.writeBooleanField(REQUIRED, field.isRequired()); generator.writeFieldName(TYPE); toJson(field.type(), generator); generator.writeEndObject(); } generator.writeEndArray(); generator.writeEndObject(); }
Example 6
Source File: JSONDump.java From pysonar2 with Apache License 2.0 | 6 votes |
private static void writeRefJson(Node ref, Binding binding, JsonGenerator json) throws IOException { if (binding.getFile() != null) { String path = binding.qname.replace(".", "/").replace("%20", "."); String key = ref.file + ":" + ref.start; if (!seenRef.contains(key)) { seenRef.add(key); if (binding.start >= 0 && ref.start >= 0 && !binding.isBuiltin()) { json.writeStartObject(); json.writeStringField("sym", path); json.writeStringField("file", ref.file); json.writeNumberField("start", ref.start); json.writeNumberField("end", ref.end); json.writeBooleanField("builtin", binding.isBuiltin()); json.writeEndObject(); } } } }
Example 7
Source File: JsonModelWriter.java From phoebus with Eclipse Public License 1.0 | 6 votes |
private static void writeLeafDetail(final JsonGenerator jg, final AlarmTreeLeaf item) throws Exception { jg.writeStringField(JsonTags.DESCRIPTION, item.getDescription()); if (! item.isEnabled()) jg.writeBooleanField(JsonTags.ENABLED, false); if (! item.isLatching()) jg.writeBooleanField(JsonTags.LATCHING, false); if (! item.isAnnunciating()) jg.writeBooleanField(JsonTags.ANNUNCIATING, false); if (item.getDelay() > 0) jg.writeNumberField(JsonTags.DELAY, item.getDelay()); if (item.getCount() > 0) jg.writeNumberField(JsonTags.COUNT, item.getCount()); if (! item.getFilter().isEmpty()) jg.writeStringField(JsonTags.FILTER, item.getFilter()); }
Example 8
Source File: Configuration.java From flink with Apache License 2.0 | 6 votes |
/** * Write property and its attributes as json format to given * {@link JsonGenerator}. * * @param jsonGen json writer * @param config configuration * @param name property name * @throws IOException */ private static void appendJSONProperty(JsonGenerator jsonGen, Configuration config, String name, ConfigRedactor redactor) throws IOException { // skip writing if given property name is empty or null if(!Strings.isNullOrEmpty(name) && jsonGen != null) { jsonGen.writeStartObject(); jsonGen.writeStringField("key", name); jsonGen.writeStringField("value", redactor.redact(name, config.get(name))); jsonGen.writeBooleanField("isFinal", config.finalParameters.contains(name)); String[] resources = config.updatingResource != null ? config.updatingResource.get(name) : null; String resource = UNKNOWN_RESOURCE; if (resources != null && resources.length > 0) { resource = resources[0]; } jsonGen.writeStringField("resource", resource); jsonGen.writeEndObject(); } }
Example 9
Source File: OAuth2ExceptionDataResultJsonSerializer.java From onetwo with Apache License 2.0 | 6 votes |
@Override public void serialize(OAuth2Exception value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { jgen.writeStartObject(); jgen.writeStringField("code", value.getOAuth2ErrorCode()); jgen.writeStringField("message", value.getMessage()); jgen.writeBooleanField("success", false); jgen.writeBooleanField("error", true); if (value.getAdditionalInformation()!=null) { for (Entry<String, String> entry : value.getAdditionalInformation().entrySet()) { String key = entry.getKey(); String add = entry.getValue(); jgen.writeStringField(key, add); } } jgen.writeEndObject(); }
Example 10
Source File: CandlestickEventSerializer.java From zheshiyigeniubidexiangmu with MIT License | 5 votes |
@Override public void serialize(CandlestickEvent candlestickEvent, JsonGenerator gen, SerializerProvider serializers) throws IOException { gen.writeStartObject(); // Write header gen.writeStringField("e", candlestickEvent.getEventType()); gen.writeNumberField("E", candlestickEvent.getEventTime()); gen.writeStringField("s", candlestickEvent.getSymbol()); // Write candlestick data gen.writeObjectFieldStart("k"); gen.writeNumberField("t", candlestickEvent.getOpenTime()); gen.writeNumberField("T", candlestickEvent.getCloseTime()); gen.writeStringField("i", candlestickEvent.getIntervalId()); gen.writeNumberField("f", candlestickEvent.getFirstTradeId()); gen.writeNumberField("L", candlestickEvent.getLastTradeId()); gen.writeStringField("o", candlestickEvent.getOpen()); gen.writeStringField("c", candlestickEvent.getClose()); gen.writeStringField("h", candlestickEvent.getHigh()); gen.writeStringField("l", candlestickEvent.getLow()); gen.writeStringField("v", candlestickEvent.getVolume()); gen.writeNumberField("n", candlestickEvent.getNumberOfTrades()); gen.writeBooleanField("x", candlestickEvent.getBarFinal()); gen.writeStringField("q", candlestickEvent.getQuoteAssetVolume()); gen.writeStringField("V", candlestickEvent.getTakerBuyBaseAssetVolume()); gen.writeStringField("Q", candlestickEvent.getTakerBuyQuoteAssetVolume()); gen.writeEndObject(); }
Example 11
Source File: TableStateIOProvider.java From constellation with Apache License 2.0 | 5 votes |
@Override public void writeObject(final Attribute attribute, final int elementId, final JsonGenerator jsonGenerator, final GraphReadMethods graph, final GraphByteWriter byteWriter, final boolean verbose) throws IOException { if (verbose || !graph.isDefaultValue(attribute.getId(), elementId)) { final TableState state = graph.getObjectValue(attribute.getId(), elementId); if (state == null) { jsonGenerator.writeNullField(attribute.getName()); } else { jsonGenerator.writeObjectFieldStart(attribute.getName()); jsonGenerator.writeNumberField("posx", state.viewPosition.x); jsonGenerator.writeNumberField("posy", state.viewPosition.y); jsonGenerator.writeBooleanField(SELECTED_ONLY, state.selectedOnly); jsonGenerator.writeArrayFieldStart("columns"); for (final ColumnState cs : state.columns) { jsonGenerator.writeStartObject(); jsonGenerator.writeStringField(LABEL, cs.label); jsonGenerator.writeStringField("segment", cs.segment.toString()); jsonGenerator.writeNumberField("width", cs.width); jsonGenerator.writeEndObject(); } jsonGenerator.writeEndArray(); jsonGenerator.writeArrayFieldStart("sortOrder"); for (final String so : state.sortOrder) { jsonGenerator.writeString(so); } jsonGenerator.writeEndArray(); jsonGenerator.writeEndObject(); } } }
Example 12
Source File: ClassSerializer.java From Stargraph with MIT License | 5 votes |
@Override public void serialize(ClassEntity value, JsonGenerator g, SerializerProvider provider) throws IOException { g.writeStartObject(); g.writeStringField("id", value.getId()); g.writeStringField("value", value.getValue()); g.writeBooleanField("complex", value.isComplex()); g.writeEndObject(); }
Example 13
Source File: NamedSelectionStateIOProvider.java From constellation with Apache License 2.0 | 5 votes |
@Override public void writeObject(final Attribute attr, final int elementId, final JsonGenerator jsonGenerator, final GraphReadMethods graph, final GraphByteWriter byteWriter, final boolean verbose) throws IOException { if (verbose || !graph.isDefaultValue(attr.getId(), elementId)) { final NamedSelectionState state = (NamedSelectionState) graph.getObjectValue(attr.getId(), elementId); if (state == null) { jsonGenerator.writeNullField(attr.getName()); } else { jsonGenerator.writeObjectFieldStart(attr.getName()); // Note the number of selections being saved: jsonGenerator.writeNumberField(QUANTITY, state.getSelectionCount()); // Write the currently allocated state list: jsonGenerator.writeNumberField(ALLOCATED, convertFromBitSet(state.getCurrentlyAllocated())); // Write the current dim and select result states: jsonGenerator.writeBooleanField(DIM_OTHERS, state.isDimOthers()); jsonGenerator.writeBooleanField(SELECT_RESULTS, state.isSelectResults()); jsonGenerator.writeArrayFieldStart(SELECTION); for (NamedSelection item : state.getNamedSelections()) { addSelection(jsonGenerator, item); } jsonGenerator.writeEndArray(); jsonGenerator.writeEndObject(); } } }
Example 14
Source File: PrefixConfigBindMap.java From kripton with Apache License 2.0 | 5 votes |
@Override public int serializeOnJackson(PrefixConfig object, JsonGenerator jacksonSerializer) throws Exception { jacksonSerializer.writeStartObject(); int fieldCount=0; // Serialized Field: // field defaultCountry (mapped with "defaultCountry") if (object.defaultCountry!=null) { fieldCount++; jacksonSerializer.writeStringField("defaultCountry", object.defaultCountry); } // field dialogTimeout (mapped with "dialogTimeout") fieldCount++; jacksonSerializer.writeNumberField("dialogTimeout", object.dialogTimeout); // field dualBillingPrefix (mapped with "dualBillingPrefix") if (object.dualBillingPrefix!=null) { fieldCount++; jacksonSerializer.writeStringField("dualBillingPrefix", object.dualBillingPrefix); } // field enabled (mapped with "enabled") fieldCount++; jacksonSerializer.writeBooleanField("enabled", object.enabled); // field id (mapped with "id") fieldCount++; jacksonSerializer.writeNumberField("id", object.id); jacksonSerializer.writeEndObject(); return fieldCount; }
Example 15
Source File: WidgetConfigPropertiesSerializer.java From entando-core with GNU Lesser General Public License v3.0 | 4 votes |
private void writeBooleanProperty(JsonGenerator jsonGenerator, String key, Boolean value) throws IOException { jsonGenerator.writeBooleanField(key, value); }
Example 16
Source File: JacksonStreamingWriteExample.java From journaldev with MIT License | 4 votes |
public static void main(String[] args) throws IOException { Employee emp = JacksonObjectMapperExample.createEmployee(); JsonGenerator jsonGenerator = new JsonFactory() .createGenerator(new FileOutputStream("stream_emp.txt")); //for pretty printing jsonGenerator.setPrettyPrinter(new DefaultPrettyPrinter()); jsonGenerator.writeStartObject(); // start root object jsonGenerator.writeNumberField("id", emp.getId()); jsonGenerator.writeStringField("name", emp.getName()); jsonGenerator.writeBooleanField("permanent", emp.isPermanent()); jsonGenerator.writeObjectFieldStart("address"); //start address object jsonGenerator.writeStringField("street", emp.getAddress().getStreet()); jsonGenerator.writeStringField("city", emp.getAddress().getCity()); jsonGenerator.writeNumberField("zipcode", emp.getAddress().getZipcode()); jsonGenerator.writeEndObject(); //end address object jsonGenerator.writeArrayFieldStart("phoneNumbers"); for(long num : emp.getPhoneNumbers()) jsonGenerator.writeNumber(num); jsonGenerator.writeEndArray(); jsonGenerator.writeStringField("role", emp.getRole()); jsonGenerator.writeArrayFieldStart("cities"); //start cities array for(String city : emp.getCities()) jsonGenerator.writeString(city); jsonGenerator.writeEndArray(); //closing cities array jsonGenerator.writeObjectFieldStart("properties"); Set<String> keySet = emp.getProperties().keySet(); for(String key : keySet){ String value = emp.getProperties().get(key); jsonGenerator.writeStringField(key, value); } jsonGenerator.writeEndObject(); //closing properties jsonGenerator.writeEndObject(); //closing root object jsonGenerator.flush(); jsonGenerator.close(); }
Example 17
Source File: MetadataDocumentJsonSerializer.java From olingo-odata4 with Apache License 2.0 | 4 votes |
private void appendConstantExpression(final JsonGenerator json, final EdmConstantExpression constExp, String termName) throws SerializerException, IOException { switch (constExp.getExpressionType()) { case Binary: json.writeObjectFieldStart(termName); json.writeStringField(DOLLAR + constExp.getExpressionName(), constExp.getValueAsString()); json.writeEndObject(); break; case Date: json.writeObjectFieldStart(termName); json.writeStringField(DOLLAR + constExp.getExpressionName(), constExp.getValueAsString()); json.writeEndObject(); break; case DateTimeOffset: json.writeObjectFieldStart(termName); json.writeStringField(DOLLAR + constExp.getExpressionName(), constExp.getValueAsString()); json.writeEndObject(); break; case Decimal: json.writeObjectFieldStart(termName); json.writeStringField(DOLLAR + constExp.getExpressionName(), constExp.getValueAsString()); json.writeEndObject(); break; case Float: json.writeObjectFieldStart(termName); json.writeStringField(DOLLAR + constExp.getExpressionName(), constExp.getValueAsString()); json.writeEndObject(); break; case Int: json.writeObjectFieldStart(termName); json.writeStringField(DOLLAR + constExp.getExpressionName(), constExp.getValueAsString()); json.writeEndObject(); break; case Duration: json.writeObjectFieldStart(termName); json.writeStringField(DOLLAR + constExp.getExpressionName(), constExp.getValueAsString()); json.writeEndObject(); break; case EnumMember: json.writeObjectFieldStart(termName); json.writeStringField(DOLLAR + constExp.getExpressionName(), constExp.getValueAsString()); json.writeEndObject(); break; case Guid: json.writeObjectFieldStart(termName); json.writeStringField("$" + constExp.getExpressionName(), constExp.getValueAsString()); json.writeEndObject(); break; case TimeOfDay: json.writeObjectFieldStart(termName); json.writeStringField(DOLLAR + constExp.getExpressionName(), constExp.getValueAsString()); json.writeEndObject(); break; case Bool: if (termName != null && termName.length() > 0) { json.writeBooleanField(termName, Boolean.valueOf(constExp.getValueAsString())); } else { json.writeBoolean(Boolean.valueOf(constExp.getValueAsString())); } break; case String: if (termName != null && termName.length() > 0) { json.writeStringField(termName, constExp.getValueAsString()); } else { json.writeString(constExp.getValueAsString()); } break; default: throw new IllegalArgumentException("Unkown ExpressionType " + "for constant expression: " + constExp.getExpressionType()); } }
Example 18
Source File: TextureAnimationBindMap.java From kripton with Apache License 2.0 | 4 votes |
@Override public int serializeOnJackson(TextureAnimation object, JsonGenerator jacksonSerializer) throws Exception { jacksonSerializer.writeStartObject(); int fieldCount=0; // Serialized Field: // field name (mapped with "name") if (object.getName()!=null) { fieldCount++; jacksonSerializer.writeStringField("name", object.getName()); } // field loop (mapped with "loop") fieldCount++; jacksonSerializer.writeBooleanField("loop", object.isLoop()); // field rate (mapped with "rate") fieldCount++; jacksonSerializer.writeNumberField("rate", object.getRate()); // field frames (mapped with "frames") if (object.frames!=null) { fieldCount++; int n=object.frames.size(); TextureKeyFrame item; // write wrapper tag jacksonSerializer.writeFieldName("frames"); jacksonSerializer.writeStartArray(); for (int i=0; i<n; i++) { item=object.frames.get(i); if (item==null) { jacksonSerializer.writeNull(); } else { textureKeyFrameBindMap.serializeOnJackson(item, jacksonSerializer); } } jacksonSerializer.writeEndArray(); } jacksonSerializer.writeEndObject(); return fieldCount; }
Example 19
Source File: TranslationBindMap.java From kripton with Apache License 2.0 | 4 votes |
@Override public int serializeOnJackson(Translation object, JsonGenerator jacksonSerializer) throws Exception { jacksonSerializer.writeStartObject(); int fieldCount=0; // Serialized Field: // field name (mapped with "name") if (object.getName()!=null) { fieldCount++; jacksonSerializer.writeStringField("name", object.getName()); } // field loop (mapped with "loop") fieldCount++; jacksonSerializer.writeBooleanField("loop", object.isLoop()); // field rate (mapped with "rate") fieldCount++; jacksonSerializer.writeNumberField("rate", object.getRate()); // field frames (mapped with "frames") if (object.frames!=null) { fieldCount++; int n=object.frames.size(); TranslationFrame item; // write wrapper tag jacksonSerializer.writeFieldName("frames"); jacksonSerializer.writeStartArray(); for (int i=0; i<n; i++) { item=object.frames.get(i); if (item==null) { jacksonSerializer.writeNull(); } else { translationFrameBindMap.serializeOnJackson(item, jacksonSerializer); } } jacksonSerializer.writeEndArray(); } jacksonSerializer.writeEndObject(); return fieldCount; }
Example 20
Source File: NodeSerializer.java From pinpoint with Apache License 2.0 | 4 votes |
private void writeHistogram(JsonGenerator jgen, Node node) throws IOException { final ServiceType serviceType = node.getServiceType(); final NodeHistogram nodeHistogram = node.getNodeHistogram(); // FIXME isn't this all ServiceTypes that can be a node? if (serviceType.isWas() || serviceType.isTerminal() || serviceType.isUnknown() || serviceType.isUser() || serviceType.isQueue() || serviceType.isAlias()) { Histogram applicationHistogram = nodeHistogram.getApplicationHistogram(); if (applicationHistogram == null) { jgen.writeBooleanField("hasAlert", false); // for go.js } else { jgen.writeNumberField("totalCount", applicationHistogram.getTotalCount()); // for go.js jgen.writeNumberField("errorCount", applicationHistogram.getTotalErrorCount()); jgen.writeNumberField("slowCount", applicationHistogram.getSlowCount()); if (applicationHistogram.getTotalCount() == 0) { jgen.writeBooleanField("hasAlert", false); // for go.js } else { long error = applicationHistogram.getTotalErrorCount() / applicationHistogram.getTotalCount(); if (error * 100 > 10) { jgen.writeBooleanField("hasAlert", true); // for go.js } else { jgen.writeBooleanField("hasAlert", false); // for go.js } } } if (applicationHistogram == null) { writeEmptyObject(jgen, "histogram"); } else { jgen.writeObjectField("histogram", applicationHistogram); } if (NodeType.DETAILED == node.getNodeType()) { Map<String, Histogram> agentHistogramMap = nodeHistogram.getAgentHistogramMap(); if (agentHistogramMap == null) { writeEmptyObject(jgen, "agentHistogram"); } else { jgen.writeObjectField("agentHistogram", agentHistogramMap); } } } else { jgen.writeBooleanField("hasAlert", false); // for go.js } // FIXME isn't this all ServiceTypes that can be a node? if (serviceType.isWas() || serviceType.isUser() || serviceType.isTerminal() || serviceType.isUnknown() || serviceType.isQueue() || serviceType.isAlias()) { List<ResponseTimeViewModel> applicationTimeSeriesHistogram = nodeHistogram.getApplicationTimeHistogram(); if (applicationTimeSeriesHistogram == null) { writeEmptyArray(jgen, "timeSeriesHistogram"); } else { jgen.writeObjectField("timeSeriesHistogram", applicationTimeSeriesHistogram); } if (NodeType.DETAILED == node.getNodeType()) { AgentResponseTimeViewModelList agentTimeSeriesHistogram = nodeHistogram.getAgentTimeHistogram(); jgen.writeObject(agentTimeSeriesHistogram); } } }