Java Code Examples for org.apache.tinkerpop.shaded.jackson.core.JsonGenerator#writeStartObject()
The following examples show how to use
org.apache.tinkerpop.shaded.jackson.core.JsonGenerator#writeStartObject() .
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: GraphSONTypeSerializerV3d0.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override public WritableTypeId writeTypePrefix(final JsonGenerator jsonGenerator, final WritableTypeId writableTypeId) throws IOException { if (writableTypeId.valueShape == JsonToken.START_OBJECT) { if (writableTypeId.forValue instanceof Map) { writeTypePrefix(jsonGenerator, getTypeIdResolver().idFromValueAndType(writableTypeId.forValue, getClassFromObject(writableTypeId.forValue))); jsonGenerator.writeStartArray(); } else { jsonGenerator.writeStartObject(); } } else if (writableTypeId.valueShape == JsonToken.START_ARRAY) { if (writableTypeId.forValue instanceof List || writableTypeId.forValue instanceof Set) { writeTypePrefix(jsonGenerator, getTypeIdResolver().idFromValueAndType(writableTypeId.forValue, getClassFromObject(writableTypeId.forValue))); jsonGenerator.writeStartArray(); } else { jsonGenerator.writeStartArray(); } } else if (canWriteTypeId()) { writeTypePrefix(jsonGenerator, getTypeIdResolver().idFromValueAndType(writableTypeId.forValue, getClassFromObject(writableTypeId.forValue))); } else { throw new IllegalStateException("Could not write prefix: shape[" + writableTypeId.valueShape + "] value[" + writableTypeId.forValue + "]"); } return writableTypeId; }
Example 2
Source File: HugeGraphSONModule.java From hugegraph with Apache License 2.0 | 6 votes |
@Override public void serialize(HugeEdge edge, JsonGenerator generator, SerializerProvider provider) throws IOException { edge.forceLoad(); generator.writeStartObject(); // Write id, label, type this.writeIdField("id", edge.id(), generator); generator.writeStringField("label", edge.label()); generator.writeStringField("type", "edge"); HugeVertex outVertex = (HugeVertex) edge.outVertex(); HugeVertex inVertex = (HugeVertex) edge.inVertex(); this.writeIdField("outV", outVertex.id(), generator); generator.writeStringField("outVLabel", outVertex.label()); this.writeIdField("inV", inVertex.id(), generator); generator.writeStringField("inVLabel", inVertex.label()); this.writePropertiesField(edge.getFilledProperties(), generator, provider); generator.writeEndObject(); }
Example 3
Source File: MetricsModule.java From hugegraph with Apache License 2.0 | 6 votes |
@Override public void serialize(Meter meter, JsonGenerator json, SerializerProvider provider) throws IOException { json.writeStartObject(); json.writeNumberField("count", meter.getCount()); json.writeNumberField("m15_rate", meter.getFifteenMinuteRate() * this.rateFactor); json.writeNumberField("m1_rate", meter.getOneMinuteRate() * this.rateFactor); json.writeNumberField("m5_rate", meter.getFiveMinuteRate() * this.rateFactor); json.writeNumberField("mean_rate", meter.getMeanRate() * this.rateFactor); json.writeStringField("units", this.rateUnit); json.writeEndObject(); }
Example 4
Source File: MetricsModule.java From hugegraph with Apache License 2.0 | 6 votes |
@Override public void serialize(Histogram histogram, JsonGenerator json, SerializerProvider provider) throws IOException { json.writeStartObject(); final Snapshot snapshot = histogram.getSnapshot(); json.writeNumberField("count", histogram.getCount()); json.writeNumberField("max", snapshot.getMax()); json.writeNumberField("mean", snapshot.getMean()); json.writeNumberField("min", snapshot.getMin()); json.writeNumberField("p50", snapshot.getMedian()); json.writeNumberField("p75", snapshot.get75thPercentile()); json.writeNumberField("p95", snapshot.get95thPercentile()); json.writeNumberField("p98", snapshot.get98thPercentile()); json.writeNumberField("p99", snapshot.get99thPercentile()); json.writeNumberField("p999", snapshot.get999thPercentile()); if (this.showSamples) { json.writeObjectField("values", snapshot.getValues()); } json.writeNumberField("stddev", snapshot.getStdDev()); json.writeEndObject(); }
Example 5
Source File: ToyTriangle.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serialize(final ToyTriangle toyTriangle, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException, JsonGenerationException { jsonGenerator.writeStartObject(); jsonGenerator.writeObjectField("x", toyTriangle.x); jsonGenerator.writeObjectField("y", toyTriangle.y); jsonGenerator.writeObjectField("z", toyTriangle.z); jsonGenerator.writeEndObject(); }
Example 6
Source File: TraversalSerializersV3d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serialize(final Bytecode.Binding binding, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { jsonGenerator.writeStartObject(); jsonGenerator.writeStringField(GraphSONTokens.KEY, binding.variable()); jsonGenerator.writeObjectField(GraphSONTokens.VALUE, binding.value()); jsonGenerator.writeEndObject(); }
Example 7
Source File: TraversalSerializersV2d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serialize(final TraversalStrategy traversalStrategy, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { jsonGenerator.writeStartObject(); for (final Map.Entry<Object, Object> entry : ConfigurationConverter.getMap(traversalStrategy.getConfiguration()).entrySet()) { jsonGenerator.writeObjectField((String) entry.getKey(), entry.getValue()); } jsonGenerator.writeEndObject(); }
Example 8
Source File: TinkerIoRegistryV1d0.java From tinkergraph-gremlin with Apache License 2.0 | 5 votes |
@Override public void serializeWithType(final TinkerGraph graph, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException { jsonGenerator.writeStartObject(); jsonGenerator.writeStringField(GraphSONTokens.CLASS, TinkerGraph.class.getName()); jsonGenerator.writeFieldName(GraphSONTokens.VERTICES); jsonGenerator.writeStartArray(); jsonGenerator.writeString(ArrayList.class.getName()); jsonGenerator.writeStartArray(); final Iterator<Vertex> vertices = graph.vertices(); while (vertices.hasNext()) { GraphSONUtil.writeWithType(vertices.next(), jsonGenerator, serializerProvider, typeSerializer); } jsonGenerator.writeEndArray(); jsonGenerator.writeEndArray(); jsonGenerator.writeFieldName(GraphSONTokens.EDGES); jsonGenerator.writeStartArray(); jsonGenerator.writeString(ArrayList.class.getName()); jsonGenerator.writeStartArray(); final Iterator<Edge> edges = graph.edges(); while (edges.hasNext()) { GraphSONUtil.writeWithType(edges.next(), jsonGenerator, serializerProvider, typeSerializer); } jsonGenerator.writeEndArray(); jsonGenerator.writeEndArray(); jsonGenerator.writeEndObject(); }
Example 9
Source File: GraphSONSerializersV2d0.java From tinkerpop with Apache License 2.0 | 5 votes |
private static void writeMetaProperties(final VertexProperty property, final JsonGenerator jsonGenerator, final boolean normalize) throws IOException { jsonGenerator.writeFieldName(GraphSONTokens.PROPERTIES); jsonGenerator.writeStartObject(); final Iterator<Property<Object>> metaProperties = normalize ? IteratorUtils.list((Iterator<Property<Object>>) property.properties(), Comparators.PROPERTY_COMPARATOR).iterator() : property.properties(); while (metaProperties.hasNext()) { final Property<Object> metaProperty = metaProperties.next(); jsonGenerator.writeObjectField(metaProperty.key(), metaProperty.value()); } jsonGenerator.writeEndObject(); }
Example 10
Source File: GraphSONSerializersV2d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serialize(final Tree tree, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException, JsonGenerationException { jsonGenerator.writeStartArray(); final Set<Map.Entry<Element, Tree>> set = tree.entrySet(); for (Map.Entry<Element, Tree> entry : set) { jsonGenerator.writeStartObject(); jsonGenerator.writeObjectField(GraphSONTokens.KEY, entry.getKey()); jsonGenerator.writeObjectField(GraphSONTokens.VALUE, entry.getValue()); jsonGenerator.writeEndObject(); } jsonGenerator.writeEndArray(); }
Example 11
Source File: MetricsModule.java From hugegraph with Apache License 2.0 | 5 votes |
@Override public void serialize(Counter counter, JsonGenerator json, SerializerProvider provider) throws IOException { json.writeStartObject(); json.writeNumberField("count", counter.getCount()); json.writeEndObject(); }
Example 12
Source File: MetricsModule.java From hugegraph with Apache License 2.0 | 5 votes |
@Override public void serialize(Gauge gauge, JsonGenerator json, SerializerProvider provider) throws IOException { json.writeStartObject(); final Object value; try { value = gauge.getValue(); json.writeObjectField("value", value); } catch (RuntimeException e) { json.writeObjectField("error", e.toString()); } json.writeEndObject(); }
Example 13
Source File: TraversalSerializersV3d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serialize(final Lambda lambda, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { jsonGenerator.writeStartObject(); jsonGenerator.writeStringField(GraphSONTokens.SCRIPT, lambda.getLambdaScript()); jsonGenerator.writeStringField(GraphSONTokens.LANGUAGE, lambda.getLambdaLanguage()); jsonGenerator.writeNumberField(GraphSONTokens.ARGUMENTS, lambda.getLambdaArguments()); jsonGenerator.writeEndObject(); }
Example 14
Source File: HugeGraphSONModule.java From hugegraph with Apache License 2.0 | 5 votes |
@Override public void serialize(Shard shard, JsonGenerator jsonGenerator, SerializerProvider provider) throws IOException { jsonGenerator.writeStartObject(); jsonGenerator.writeStringField("start", shard.start()); jsonGenerator.writeStringField("end", shard.end()); jsonGenerator.writeNumberField("length", shard.length()); jsonGenerator.writeEndObject(); }
Example 15
Source File: GraphSONSerializersV3d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serialize(final Property property, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { jsonGenerator.writeStartObject(); jsonGenerator.writeObjectField(GraphSONTokens.KEY, property.key()); jsonGenerator.writeObjectField(GraphSONTokens.VALUE, property.value()); jsonGenerator.writeEndObject(); }
Example 16
Source File: GraphSONSerializersV3d0.java From tinkerpop with Apache License 2.0 | 5 votes |
private void writeProperties(final Edge edge, final JsonGenerator jsonGenerator) throws IOException { final Iterator<Property<Object>> elementProperties = normalize ? IteratorUtils.list(edge.properties(), Comparators.PROPERTY_COMPARATOR).iterator() : edge.properties(); if (elementProperties.hasNext()) { jsonGenerator.writeFieldName(GraphSONTokens.PROPERTIES); jsonGenerator.writeStartObject(); elementProperties.forEachRemaining(prop -> safeWriteObjectField(jsonGenerator, prop.key(), prop)); jsonGenerator.writeEndObject(); } }
Example 17
Source File: GraphSONSerializersV2d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serialize(final Vertex vertex, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { jsonGenerator.writeStartObject(); jsonGenerator.writeObjectField(GraphSONTokens.ID, vertex.id()); jsonGenerator.writeStringField(GraphSONTokens.LABEL, vertex.label()); writeProperties(vertex, jsonGenerator); jsonGenerator.writeEndObject(); }
Example 18
Source File: TraversalSerializersV2d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serialize(final Traverser traverserInstance, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { jsonGenerator.writeStartObject(); jsonGenerator.writeObjectField(GraphSONTokens.BULK, traverserInstance.bulk()); jsonGenerator.writeObjectField(GraphSONTokens.VALUE, traverserInstance.get()); jsonGenerator.writeEndObject(); }
Example 19
Source File: GraphSONUtil.java From tinkerpop with Apache License 2.0 | 4 votes |
public static void writeStartObject(final Object o, final JsonGenerator jsonGenerator, final TypeSerializer typeSerializer) throws IOException { if (typeSerializer != null) typeSerializer.writeTypePrefixForObject(o, jsonGenerator); else jsonGenerator.writeStartObject(); }
Example 20
Source File: Geoshape.java From titan1withtp3.1 with Apache License 2.0 | 4 votes |
@Override public void serialize(Geoshape value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { jgen.writeStartObject(); jgen.writeFieldName("type"); switch(value.getType()) { case POLYGON: throw new UnsupportedOperationException("Ploygons are not supported"); case BOX: jgen.writeString("Polygon"); jgen.writeFieldName("coordinates"); jgen.writeStartArray(); jgen.writeStartArray(); jgen.writeNumber(value.coordinates[1][0]); jgen.writeNumber(value.coordinates[0][0]); jgen.writeEndArray(); jgen.writeStartArray(); jgen.writeNumber(value.coordinates[1][1]); jgen.writeNumber(value.coordinates[0][0]); jgen.writeEndArray(); jgen.writeStartArray(); jgen.writeNumber(value.coordinates[1][1]); jgen.writeNumber(value.coordinates[0][1]); jgen.writeEndArray(); jgen.writeStartArray(); jgen.writeNumber(value.coordinates[1][0]); jgen.writeNumber(value.coordinates[0][1]); jgen.writeEndArray(); jgen.writeEndArray(); break; case CIRCLE: jgen.writeString("Circle"); jgen.writeFieldName("radius"); jgen.writeNumber(value.getRadius()); jgen.writeFieldName("coordinates"); jgen.writeStartArray(); jgen.writeNumber(value.coordinates[1][0]); jgen.writeNumber(value.coordinates[0][0]); jgen.writeEndArray(); break; case POINT: jgen.writeString("Point"); jgen.writeFieldName("coordinates"); jgen.writeStartArray(); jgen.writeNumber(value.coordinates[1][0]); jgen.writeNumber(value.coordinates[0][0]); jgen.writeEndArray(); break; } jgen.writeEndObject(); }