Java Code Examples for org.apache.tinkerpop.shaded.jackson.core.JsonGenerator#writeEndObject()
The following examples show how to use
org.apache.tinkerpop.shaded.jackson.core.JsonGenerator#writeEndObject() .
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: HugeGraphSONModule.java From hugegraph with Apache License 2.0 | 6 votes |
@Override public void serialize(HugeVertex vertex, JsonGenerator generator, SerializerProvider provider) throws IOException { vertex.forceLoad(); generator.writeStartObject(); this.writeIdField("id", vertex.id(), generator); generator.writeStringField("label", vertex.label()); generator.writeStringField("type", "vertex"); this.writePropertiesField(vertex.getFilledProperties(), generator, provider); generator.writeEndObject(); }
Example 2
Source File: TinkerIoRegistryV3d0.java From tinkergraph-gremlin with Apache License 2.0 | 6 votes |
@Override public void serialize(final TinkerGraph graph, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { jsonGenerator.writeStartObject(); jsonGenerator.writeFieldName(GraphSONTokens.VERTICES); jsonGenerator.writeStartArray(); final Iterator<Vertex> vertices = graph.vertices(); while (vertices.hasNext()) { serializerProvider.defaultSerializeValue(vertices.next(), jsonGenerator); } jsonGenerator.writeEndArray(); jsonGenerator.writeFieldName(GraphSONTokens.EDGES); jsonGenerator.writeStartArray(); final Iterator<Edge> edges = graph.edges(); while (edges.hasNext()) { serializerProvider.defaultSerializeValue(edges.next(), jsonGenerator); } jsonGenerator.writeEndArray(); jsonGenerator.writeEndObject(); }
Example 3
Source File: TraversalSerializersV3d0.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override public void serialize(final P p, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { jsonGenerator.writeStartObject(); jsonGenerator.writeStringField(GraphSONTokens.PREDICATE, p instanceof ConnectiveP ? p instanceof AndP ? GraphSONTokens.AND : GraphSONTokens.OR : p.getBiPredicate().toString()); if (p instanceof ConnectiveP) { jsonGenerator.writeArrayFieldStart(GraphSONTokens.VALUE); for (final P<?> predicate : ((ConnectiveP<?>) p).getPredicates()) { jsonGenerator.writeObject(predicate); } jsonGenerator.writeEndArray(); } else jsonGenerator.writeObjectField(GraphSONTokens.VALUE, p.getValue()); jsonGenerator.writeEndObject(); }
Example 4
Source File: AbstractGraphSONMessageSerializerV1d0.java From tinkerpop with Apache License 2.0 | 6 votes |
public void ser(final ResponseMessage responseMessage, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException, JsonProcessingException { jsonGenerator.writeStartObject(); if (typeSerializer != null) jsonGenerator.writeStringField(GraphSONTokens.CLASS, HashMap.class.getName()); jsonGenerator.writeStringField(SerTokens.TOKEN_REQUEST, responseMessage.getRequestId() != null ? responseMessage.getRequestId().toString() : null); jsonGenerator.writeObjectFieldStart(SerTokens.TOKEN_STATUS); if (typeSerializer != null) jsonGenerator.writeStringField(GraphSONTokens.CLASS, HashMap.class.getName()); jsonGenerator.writeStringField(SerTokens.TOKEN_MESSAGE, responseMessage.getStatus().getMessage()); jsonGenerator.writeNumberField(SerTokens.TOKEN_CODE, responseMessage.getStatus().getCode().getValue()); jsonGenerator.writeObjectField(SerTokens.TOKEN_ATTRIBUTES, responseMessage.getStatus().getAttributes()); jsonGenerator.writeEndObject(); jsonGenerator.writeObjectFieldStart(SerTokens.TOKEN_RESULT); if (typeSerializer != null) jsonGenerator.writeStringField(GraphSONTokens.CLASS, HashMap.class.getName()); if (null == responseMessage.getResult().getData()) jsonGenerator.writeNullField(SerTokens.TOKEN_DATA); else GraphSONUtil.writeWithType(SerTokens.TOKEN_DATA, responseMessage.getResult().getData(), jsonGenerator, serializerProvider, typeSerializer); jsonGenerator.writeObjectField(SerTokens.TOKEN_META, responseMessage.getResult().getMeta()); jsonGenerator.writeEndObject(); jsonGenerator.writeEndObject(); }
Example 5
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 6
Source File: GraphSONSerializersV3d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serialize(final VertexProperty property, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { jsonGenerator.writeStartObject(); jsonGenerator.writeObjectField(GraphSONTokens.ID, property.id()); jsonGenerator.writeObjectField(GraphSONTokens.VALUE, property.value()); if (includeLabel) jsonGenerator.writeStringField(GraphSONTokens.LABEL, property.label()); tryWriteMetaProperties(property, jsonGenerator, normalize); jsonGenerator.writeEndObject(); }
Example 7
Source File: GraphSONSerializersV1d0.java From tinkerpop with Apache License 2.0 | 5 votes |
private static void ser(final Property property, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException { jsonGenerator.writeStartObject(); if (typeSerializer != null) jsonGenerator.writeStringField(GraphSONTokens.CLASS, HashMap.class.getName()); serializerProvider.defaultSerializeField(GraphSONTokens.KEY, property.key(), jsonGenerator); serializerProvider.defaultSerializeField(GraphSONTokens.VALUE, property.value(), jsonGenerator); jsonGenerator.writeEndObject(); }
Example 8
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 9
Source File: GraphSONSerializersV2d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serialize(final VertexProperty property, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { jsonGenerator.writeStartObject(); jsonGenerator.writeObjectField(GraphSONTokens.ID, property.id()); jsonGenerator.writeObjectField(GraphSONTokens.VALUE, property.value()); if (includeLabel) jsonGenerator.writeStringField(GraphSONTokens.LABEL, property.label()); tryWriteMetaProperties(property, jsonGenerator, normalize); jsonGenerator.writeEndObject(); }
Example 10
Source File: TraversalSerializersV2d0.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 11
Source File: GraphSONSerializersV2d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serialize(final Path path, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException, JsonGenerationException { jsonGenerator.writeStartObject(); // paths shouldn't serialize with properties if the path contains graph elements final Path p = DetachedFactory.detach(path, false); jsonGenerator.writeObjectField(GraphSONTokens.LABELS, p.labels()); jsonGenerator.writeObjectField(GraphSONTokens.OBJECTS, p.objects()); jsonGenerator.writeEndObject(); }
Example 12
Source File: GraphSONSerializersV1d0.java From tinkerpop with Apache License 2.0 | 5 votes |
private void ser(final Vertex vertex, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException { jsonGenerator.writeStartObject(); if (typeSerializer != null) jsonGenerator.writeStringField(GraphSONTokens.CLASS, HashMap.class.getName()); GraphSONUtil.writeWithType(GraphSONTokens.ID, vertex.id(), jsonGenerator, serializerProvider, typeSerializer); jsonGenerator.writeStringField(GraphSONTokens.LABEL, vertex.label()); jsonGenerator.writeStringField(GraphSONTokens.TYPE, GraphSONTokens.VERTEX); writeProperties(vertex, jsonGenerator, serializerProvider, typeSerializer); jsonGenerator.writeEndObject(); }
Example 13
Source File: HugeResource.java From hugegraph with Apache License 2.0 | 5 votes |
@Override public void serialize(HugeResource res, JsonGenerator generator, SerializerProvider provider) throws IOException { generator.writeStartObject(); generator.writeObjectField("type", res.type); generator.writeObjectField("label", res.label); generator.writeObjectField("properties", res.properties); generator.writeEndObject(); }
Example 14
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 15
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 16
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 17
Source File: TinkerIoRegistryV1d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serialize(final TinkerGraph graph, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { jsonGenerator.writeStartObject(); jsonGenerator.writeFieldName(GraphSONTokens.VERTICES); jsonGenerator.writeStartArray(); final Iterator<Vertex> vertices = graph.vertices(); while (vertices.hasNext()) { serializerProvider.defaultSerializeValue(vertices.next(), jsonGenerator); } jsonGenerator.writeEndArray(); jsonGenerator.writeFieldName(GraphSONTokens.EDGES); jsonGenerator.writeStartArray(); final Iterator<Edge> edges = graph.edges(); while (edges.hasNext()) { serializerProvider.defaultSerializeValue(edges.next(), jsonGenerator); } jsonGenerator.writeEndArray(); jsonGenerator.writeEndObject(); }
Example 18
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 19
Source File: RolePermission.java From hugegraph with Apache License 2.0 | 5 votes |
@Override public void serialize(RolePermission role, JsonGenerator generator, SerializerProvider provider) throws IOException { generator.writeStartObject(); generator.writeObjectField("roles", role.map); generator.writeEndObject(); }
Example 20
Source File: AbstractGraphSONTypeSerializer.java From tinkerpop with Apache License 2.0 | 4 votes |
protected void writeTypeSuffix(final JsonGenerator jsonGenerator) throws IOException { jsonGenerator.writeEndObject(); }