org.apache.tinkerpop.shaded.jackson.core.JsonGenerator Java Examples

The following examples show how to use org.apache.tinkerpop.shaded.jackson.core.JsonGenerator. 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 Project: tinkerpop   Author: apache   File: TraversalSerializersV3d0.java    License: Apache License 2.0 6 votes vote down vote up
@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 #2
Source Project: hugegraph   Author: hugegraph   File: HugeGraphSONModule.java    License: Apache License 2.0 6 votes vote down vote up
@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 Project: tinkerpop   Author: apache   File: GraphSONSerializersV2d0.java    License: Apache License 2.0 6 votes vote down vote up
private static void tryWriteMetaProperties(final VertexProperty property, final JsonGenerator jsonGenerator,
                                           final boolean normalize) throws IOException {
    // when "detached" you can't check features of the graph it detached from so it has to be
    // treated differently from a regular VertexProperty implementation.
    if (property instanceof DetachedVertexProperty) {
        // only write meta properties key if they exist
        if (property.properties().hasNext()) {
            writeMetaProperties(property, jsonGenerator, normalize);
        }
    } else {
        // still attached - so we can check the features to see if it's worth even trying to write the
        // meta properties key
        if (property.graph().features().vertex().supportsMetaProperties() && property.properties().hasNext()) {
            writeMetaProperties(property, jsonGenerator, normalize);
        }
    }
}
 
Example #4
Source Project: tinkergraph-gremlin   Author: ShiftLeftSecurity   File: TinkerIoRegistryV2d0.java    License: Apache License 2.0 6 votes vote down vote up
@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 #5
Source Project: tinkerpop   Author: apache   File: AbstractGraphSONMessageSerializerV1d0.java    License: Apache License 2.0 6 votes vote down vote up
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 #6
Source Project: tinkerpop   Author: apache   File: TinkerIoRegistryV3d0.java    License: Apache License 2.0 6 votes vote down vote up
@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 #7
Source Project: sqlg   Author: pietermartin   File: SchemaTable.java    License: MIT License 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public void serializeWithType(final SchemaTable schemaTable, final JsonGenerator jsonGenerator,
                              final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException, JsonProcessingException {
    // when the type is included add "class" as a key and then try to utilize as much of the
    // default serialization provided by jackson data-bind as possible.  for example, write
    // the uuid as an object so that when jackson serializes it, it uses the uuid serializer
    // to write it out with the type.  in this way, data-bind should be able to deserialize
    // it back when types are embedded.
    typeSerializer.writeTypePrefixForScalar(schemaTable, jsonGenerator);
    final Map<String, Object> m = new LinkedHashMap<>();
    m.put("schema", schemaTable.getSchema());
    m.put("table", schemaTable.getTable());
    jsonGenerator.writeObject(m);
    typeSerializer.writeTypeSuffixForScalar(schemaTable, jsonGenerator);
}
 
Example #8
Source Project: tinkerpop   Author: apache   File: GraphSONSerializersV2d0.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void serialize(final Metrics metrics, final JsonGenerator jsonGenerator,
                      final SerializerProvider serializerProvider) throws IOException {
    final Map<String, Object> m = new HashMap<>();
    m.put(GraphSONTokens.ID, metrics.getId());
    m.put(GraphSONTokens.NAME, metrics.getName());
    m.put(GraphSONTokens.COUNTS, metrics.getCounts());
    m.put(GraphSONTokens.DURATION, metrics.getDuration(TimeUnit.NANOSECONDS) / 1000000d);

    if (!metrics.getAnnotations().isEmpty()) {
        m.put(GraphSONTokens.ANNOTATIONS, metrics.getAnnotations());
    }
    if (!metrics.getNested().isEmpty()) {
        final List<Metrics> nested = new ArrayList<>();
        metrics.getNested().forEach(it -> nested.add(it));
        m.put(GraphSONTokens.METRICS, nested);
    }
    jsonGenerator.writeObject(m);
}
 
Example #9
Source Project: tinkerpop   Author: apache   File: GraphSONSerializersV3d0.java    License: Apache License 2.0 6 votes vote down vote up
private static void tryWriteMetaProperties(final VertexProperty property, final JsonGenerator jsonGenerator,
                                           final boolean normalize) throws IOException {
    // when "detached" you can't check features of the graph it detached from so it has to be
    // treated differently from a regular VertexProperty implementation.
    if (property instanceof DetachedVertexProperty) {
        // only write meta properties key if they exist
        if (property.properties().hasNext()) {
            writeMetaProperties(property, jsonGenerator, normalize);
        }
    } else {
        // still attached - so we can check the features to see if it's worth even trying to write the
        // meta properties key
        if (property.graph().features().vertex().supportsMetaProperties() && property.properties().hasNext()) {
            writeMetaProperties(property, jsonGenerator, normalize);
        }
    }
}
 
Example #10
Source Project: tinkerpop   Author: apache   File: GraphSONSerializersV3d0.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void serialize(final TraversalExplanation traversalExplanation, final JsonGenerator jsonGenerator,
                      final SerializerProvider serializerProvider) throws IOException {
    final Map<String, Object> m = new HashMap<>();
    m.put(GraphSONTokens.ORIGINAL, getStepsAsList(traversalExplanation.getOriginalTraversal()));

    final List<Pair<TraversalStrategy, Traversal.Admin<?, ?>>> strategyTraversals = traversalExplanation.getStrategyTraversals();

    final List<Map<String, Object>> intermediates = new ArrayList<>();
    for (final Pair<TraversalStrategy, Traversal.Admin<?, ?>> pair : strategyTraversals) {
        final Map<String, Object> intermediate = new HashMap<>();
        intermediate.put(GraphSONTokens.STRATEGY, pair.getValue0().toString());
        intermediate.put(GraphSONTokens.CATEGORY, pair.getValue0().getTraversalCategory().getSimpleName());
        intermediate.put(GraphSONTokens.TRAVERSAL, getStepsAsList(pair.getValue1()));
        intermediates.add(intermediate);
    }
    m.put(GraphSONTokens.INTERMEDIATE, intermediates);

    if (strategyTraversals.isEmpty())
        m.put(GraphSONTokens.FINAL, getStepsAsList(traversalExplanation.getOriginalTraversal()));
    else
        m.put(GraphSONTokens.FINAL, getStepsAsList(strategyTraversals.get(strategyTraversals.size() - 1).getValue1()));

    jsonGenerator.writeObject(m);
}
 
Example #11
Source Project: hugegraph   Author: hugegraph   File: HugeResource.java    License: Apache License 2.0 5 votes vote down vote up
@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 #12
Source Project: tinkerpop   Author: apache   File: TraversalSerializersV2d0.java    License: Apache License 2.0 5 votes vote down vote up
@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 #13
Source Project: tinkerpop   Author: apache   File: ToyTriangle.java    License: Apache License 2.0 5 votes vote down vote up
@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 #14
Source Project: hugegraph   Author: hugegraph   File: HugeGraphSONModule.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(Optional optional,
                      JsonGenerator jsonGenerator,
                      SerializerProvider provider)
                      throws IOException {
    if (optional.isPresent()) {
        jsonGenerator.writeObject(optional.get());
    } else {
        jsonGenerator.writeObject(null);
    }
}
 
Example #15
Source Project: tinkerpop   Author: apache   File: GraphSONSerializersV1d0.java    License: Apache License 2.0 5 votes vote down vote up
private void writeProperties(final Vertex vertex, final JsonGenerator jsonGenerator,
                                    final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException {
    jsonGenerator.writeObjectFieldStart(GraphSONTokens.PROPERTIES);
    if (typeSerializer != null) jsonGenerator.writeStringField(GraphSONTokens.CLASS, HashMap.class.getName());

    final List<String> keys = normalize ?
            IteratorUtils.list(vertex.keys().iterator(), Comparator.naturalOrder()) : new ArrayList<>(vertex.keys());
    for (String key : keys) {
        final Iterator<VertexProperty<Object>> vertexProperties = normalize ?
                IteratorUtils.list(vertex.properties(key), Comparators.PROPERTY_COMPARATOR).iterator() : vertex.properties(key);

        if (vertexProperties.hasNext()) {
            jsonGenerator.writeArrayFieldStart(key);
            if (typeSerializer != null) {
                jsonGenerator.writeString(ArrayList.class.getName());
                jsonGenerator.writeStartArray();
            }

            while (vertexProperties.hasNext()) {
                serializerVertexProperty(vertexProperties.next(), jsonGenerator, serializerProvider, typeSerializer, normalize, false);
            }

            jsonGenerator.writeEndArray();
            if (typeSerializer != null) jsonGenerator.writeEndArray();
        }
    }

    jsonGenerator.writeEndObject();
}
 
Example #16
Source Project: hugegraph   Author: hugegraph   File: HugeGraphSONModule.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void serializeWithType(T value,
                              JsonGenerator jsonGenerator,
                              SerializerProvider provider,
                              TypeSerializer typeSer)
                              throws IOException {
    // https://github.com/FasterXML/jackson-databind/issues/2320
    WritableTypeId typeId = typeSer.typeId(value, JsonToken.VALUE_STRING);
    typeSer.writeTypePrefix(jsonGenerator, typeId);
    this.serialize(value, jsonGenerator, provider);
    typeSer.writeTypeSuffix(jsonGenerator, typeId);
}
 
Example #17
Source Project: tinkerpop   Author: apache   File: GraphSONUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static void writeWithType(final String key, final Object object, final JsonGenerator jsonGenerator,
                                 final SerializerProvider serializerProvider,
                                 final TypeSerializer typeSerializer) throws IOException {
    final JsonSerializer<Object> serializer = serializerProvider.findValueSerializer(object.getClass(), null);
    if (typeSerializer != null) {
        // serialize with types embedded
        if (key != null && !key.isEmpty()) jsonGenerator.writeFieldName(key);
        serializer.serializeWithType(object, jsonGenerator, serializerProvider, typeSerializer);
    } else {
        // types are not embedded, but use the serializer when possible or else custom serializers will get
        // bypassed and you end up with the default jackson serializer when you don't want it.
        if (key != null && !key.isEmpty()) jsonGenerator.writeFieldName(key);
        serializer.serialize(object, jsonGenerator, serializerProvider);
    }
}
 
Example #18
Source Project: hugegraph   Author: hugegraph   File: HugeGraphSONModule.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(VertexLabel vl,
                      JsonGenerator jsonGenerator,
                      SerializerProvider provider)
                      throws IOException {
    writeEntry(jsonGenerator, schemaSerializer.writeVertexLabel(vl));
}
 
Example #19
Source Project: tinkerpop   Author: apache   File: TraversalSerializersV2d0.java    License: Apache License 2.0 5 votes vote down vote up
@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 #20
Source Project: hugegraph   Author: hugegraph   File: HugeGraphSONModule.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(IndexLabel il,
                      JsonGenerator jsonGenerator,
                      SerializerProvider provider)
                      throws IOException {
    writeEntry(jsonGenerator, schemaSerializer.writeIndexLabel(il));
}
 
Example #21
Source Project: tinkerpop   Author: apache   File: TraversalSerializersV2d0.java    License: Apache License 2.0 5 votes vote down vote up
@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 {
        if (p.getValue() instanceof Collection) {
            jsonGenerator.writeArrayFieldStart(GraphSONTokens.VALUE);
            for (final Object object : (Collection) p.getValue()) {
                jsonGenerator.writeObject(object);
            }
            jsonGenerator.writeEndArray();
        } else
            jsonGenerator.writeObjectField(GraphSONTokens.VALUE, p.getValue());
    }
    jsonGenerator.writeEndObject();
}
 
Example #22
Source Project: tinkerpop   Author: apache   File: GraphSONSerializersV2d0.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(final TraversalMetrics traversalMetrics, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider)
        throws IOException {
    // creation of the map enables all the fields to be properly written with their type if required
    final Map<String, Object> m = new HashMap<>();
    m.put(GraphSONTokens.DURATION, traversalMetrics.getDuration(TimeUnit.NANOSECONDS) / 1000000d);
    final List<Metrics> metrics = new ArrayList<>();
    metrics.addAll(traversalMetrics.getMetrics());
    m.put(GraphSONTokens.METRICS, metrics);

    jsonGenerator.writeObject(m);
}
 
Example #23
Source Project: tinkerpop   Author: apache   File: GraphSONSerializersV2d0.java    License: Apache License 2.0 5 votes vote down vote up
@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 #24
Source Project: hugegraph   Author: hugegraph   File: HugeGraphSONModule.java    License: Apache License 2.0 5 votes vote down vote up
@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 #25
Source Project: hugegraph   Author: hugegraph   File: HugeGraphSONModule.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(File file, JsonGenerator jsonGenerator,
                      SerializerProvider provider)
                      throws IOException {
    jsonGenerator.writeStartObject();
    jsonGenerator.writeStringField("file", file.getName());
    jsonGenerator.writeEndObject();
}
 
Example #26
Source Project: tinkerpop   Author: apache   File: GraphSONSerializersV1d0.java    License: Apache License 2.0 5 votes vote down vote up
private static void ser(final Path path, final JsonGenerator jsonGenerator, final TypeSerializer typeSerializer)
        throws IOException {
    jsonGenerator.writeStartObject();
    if (typeSerializer != null) jsonGenerator.writeStringField(GraphSONTokens.CLASS, HashMap.class.getName());
    jsonGenerator.writeObjectField(GraphSONTokens.LABELS, path.labels());
    jsonGenerator.writeObjectField(GraphSONTokens.OBJECTS, path.objects());
    jsonGenerator.writeEndObject();
}
 
Example #27
Source Project: sqlg   Author: pietermartin   File: SchemaTable.java    License: MIT License 5 votes vote down vote up
@Override
public void serializeWithType(final SchemaTable schemaTable, final JsonGenerator jsonGenerator,
                              final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException {
    // when the type is included add "class" as a key and then try to utilize as much of the
    // default serialization provided by jackson data-bind as possible.  for example, write
    // the uuid as an object so that when jackson serializes it, it uses the uuid serializer
    // to write it out with the type.  in this way, data-bind should be able to deserialize
    // it back when types are embedded.
    jsonGenerator.writeStartObject();
    jsonGenerator.writeStringField(GraphSONTokens.CLASS, SchemaTable.class.getName());
    jsonGenerator.writeStringField("schema", schemaTable.getSchema());
    jsonGenerator.writeStringField("table", schemaTable.getTable());
    jsonGenerator.writeEndObject();
}
 
Example #28
Source Project: hugegraph   Author: hugegraph   File: MetricsModule.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(Counter counter, JsonGenerator json,
                      SerializerProvider provider) throws IOException {
    json.writeStartObject();
    json.writeNumberField("count", counter.getCount());
    json.writeEndObject();
}
 
Example #29
Source Project: tinkerpop   Author: apache   File: JavaTimeSerializersV3d0.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void serializeWithType(final T value, final JsonGenerator gen,
                              final SerializerProvider serializers, final TypeSerializer typeSer) throws IOException {
    typeSer.writeTypePrefixForScalar(value, gen);
    gen.writeString(value.toString());
    typeSer.writeTypeSuffixForScalar(value, gen);
}
 
Example #30
Source Project: tinkerpop   Author: apache   File: CustomId.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(final CustomId customId, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider)
        throws IOException, JsonGenerationException {
    // when types are not embedded, stringify or resort to JSON primitive representations of the
    // type so that non-jvm languages can better interoperate with the TinkerPop stack.
    jsonGenerator.writeString(customId.toString());
}