org.apache.tinkerpop.shaded.jackson.databind.jsontype.TypeSerializer Java Examples
The following examples show how to use
org.apache.tinkerpop.shaded.jackson.databind.jsontype.TypeSerializer.
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: SchemaTable.java From sqlg with MIT License | 6 votes |
@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 #2
Source File: GraphSONSerializersV1d0.java From tinkerpop with Apache License 2.0 | 6 votes |
private static void ser(final Tree tree, final JsonGenerator jsonGenerator, final TypeSerializer typeSerializer) throws IOException { jsonGenerator.writeStartObject(); if (typeSerializer != null) jsonGenerator.writeStringField(GraphSONTokens.CLASS, HashMap.class.getName()); Set<Map.Entry<Element, Tree>> set = tree.entrySet(); for(Map.Entry<Element, Tree> entry : set) { jsonGenerator.writeObjectFieldStart(entry.getKey().id().toString()); if (typeSerializer != null) jsonGenerator.writeStringField(GraphSONTokens.CLASS, HashMap.class.getName()); jsonGenerator.writeObjectField(GraphSONTokens.KEY, entry.getKey()); jsonGenerator.writeObjectField(GraphSONTokens.VALUE, entry.getValue()); jsonGenerator.writeEndObject(); } jsonGenerator.writeEndObject(); }
Example #3
Source File: GraphSONSerializersV1d0.java From tinkerpop with Apache License 2.0 | 6 votes |
private static void tryWriteMetaProperties(final VertexProperty property, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer, 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, serializerProvider, typeSerializer, 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, serializerProvider, typeSerializer, normalize); } } }
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: RecordId.java From sqlg with MIT License | 6 votes |
@SuppressWarnings("deprecation") @Override public void serializeWithType(final RecordId recordId, 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(recordId, jsonGenerator); final Map<String, Object> m = new LinkedHashMap<>(); m.put("schemaTable", recordId.getSchemaTable()); if (recordId.hasSequenceId()) { m.put("id", recordId.sequenceId()); } else { m.put("id", recordId.getIdentifiers()); } jsonGenerator.writeObject(m); typeSerializer.writeTypeSuffixForScalar(recordId, jsonGenerator); }
Example #6
Source File: GraphSONSerializersV1d0.java From tinkerpop with Apache License 2.0 | 5 votes |
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 #7
Source File: AbstractGraphSONMessageSerializerV2d0.java From tinkerpop with Apache License 2.0 | 5 votes |
public void ser(final RequestMessage requestMessage, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException { GraphSONUtil.writeStartObject(requestMessage, jsonGenerator, typeSerializer); jsonGenerator.writeStringField(SerTokens.TOKEN_REQUEST, requestMessage.getRequestId().toString()); jsonGenerator.writeStringField(SerTokens.TOKEN_OP, requestMessage.getOp()); jsonGenerator.writeStringField(SerTokens.TOKEN_PROCESSOR, requestMessage.getProcessor()); jsonGenerator.writeObjectField(SerTokens.TOKEN_ARGS, requestMessage.getArgs()); GraphSONUtil.writeEndObject(requestMessage, jsonGenerator, typeSerializer); }
Example #8
Source File: HugeGraphSONModule.java From hugegraph with Apache License 2.0 | 5 votes |
@Override public void serializeWithType(HugeVertex value, JsonGenerator generator, SerializerProvider provider, TypeSerializer typeSer) throws IOException { WritableTypeId typeId = typeSer.typeId(value, JsonToken.VALUE_STRING); typeSer.writeTypePrefix(generator, typeId); this.serialize(value, generator, provider); typeSer.writeTypeSuffix(generator, typeId); }
Example #9
Source File: JavaUtilSerializersV3d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serializeWithType(final Set set, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException { typeSerializer.writeTypePrefixForArray(set, jsonGenerator); serialize(set, jsonGenerator, serializerProvider); typeSerializer.writeTypeSuffixForArray(set, jsonGenerator); }
Example #10
Source File: JavaUtilSerializersV3d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serializeWithType(final List list, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException { typeSerializer.writeTypePrefixForArray(list, jsonGenerator); serialize(list, jsonGenerator, serializerProvider); typeSerializer.writeTypeSuffixForArray(list, jsonGenerator); }
Example #11
Source File: JavaUtilSerializersV1d0.java From tinkerpop with Apache License 2.0 | 5 votes |
private static void ser(final Map.Entry entry, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException { jsonGenerator.writeStartObject(); if (typeSerializer != null) jsonGenerator.writeStringField(GraphSONTokens.CLASS, HashMap.class.getName()); // this treatment of keys is consistent with the current GraphSONKeySerializer which extends the // StdKeySerializer final Object key = entry.getKey(); final Class cls = key.getClass(); String k; if (cls == String.class) k = (String) key; else if (Element.class.isAssignableFrom(cls)) k = ((Element) key).id().toString(); else if(Date.class.isAssignableFrom(cls)) { if (serializerProvider.isEnabled(SerializationFeature.WRITE_DATE_KEYS_AS_TIMESTAMPS)) k = String.valueOf(((Date) key).getTime()); else k = serializerProvider.getConfig().getDateFormat().format((Date) key); } else if(cls == Class.class) k = ((Class) key).getName(); else k = key.toString(); serializerProvider.defaultSerializeField(k, entry.getValue(), jsonGenerator); jsonGenerator.writeEndObject(); }
Example #12
Source File: JavaUtilSerializersV3d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serializeWithType(final Map map, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException { typeSerializer.writeTypePrefixForObject(map, jsonGenerator); serialize(map, jsonGenerator, serializerProvider); typeSerializer.writeTypeSuffixForObject(map, jsonGenerator); }
Example #13
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 #14
Source File: GraphSONSerializersV1d0.java From tinkerpop with Apache License 2.0 | 5 votes |
private void ser(final Edge edge, 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, edge.id(), jsonGenerator, serializerProvider, typeSerializer); jsonGenerator.writeStringField(GraphSONTokens.LABEL, edge.label()); jsonGenerator.writeStringField(GraphSONTokens.TYPE, GraphSONTokens.EDGE); jsonGenerator.writeStringField(GraphSONTokens.IN_LABEL, edge.inVertex().label()); jsonGenerator.writeStringField(GraphSONTokens.OUT_LABEL, edge.outVertex().label()); GraphSONUtil.writeWithType(GraphSONTokens.IN, edge.inVertex().id(), jsonGenerator, serializerProvider, typeSerializer); GraphSONUtil.writeWithType(GraphSONTokens.OUT, edge.outVertex().id(), jsonGenerator, serializerProvider, typeSerializer); writeProperties(edge, jsonGenerator, serializerProvider, typeSerializer); jsonGenerator.writeEndObject(); }
Example #15
Source File: GraphSONSerializersV1d0.java From tinkerpop with Apache License 2.0 | 5 votes |
private void writeProperties(final Edge edge, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException { final Iterator<Property<Object>> elementProperties = normalize ? IteratorUtils.list(edge.properties(), Comparators.PROPERTY_COMPARATOR).iterator() : edge.properties(); if (elementProperties.hasNext()) { jsonGenerator.writeObjectFieldStart(GraphSONTokens.PROPERTIES); if (typeSerializer != null) jsonGenerator.writeStringField(GraphSONTokens.CLASS, HashMap.class.getName()); while (elementProperties.hasNext()) { final Property<Object> elementProperty = elementProperties.next(); GraphSONUtil.writeWithType(elementProperty.key(), elementProperty.value(), jsonGenerator, serializerProvider, typeSerializer); } jsonGenerator.writeEndObject(); } }
Example #16
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 #17
Source File: HugeGraphSONModule.java From hugegraph with Apache License 2.0 | 5 votes |
@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 #18
Source File: GraphSONSerializersV1d0.java From tinkerpop with Apache License 2.0 | 5 votes |
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 #19
Source File: RecordId.java From sqlg with MIT License | 5 votes |
@Override public void serializeWithType(final RecordId recordId, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException { jsonGenerator.writeStartObject(); jsonGenerator.writeStringField(GraphSONTokens.CLASS, RecordId.class.getName()); jsonGenerator.writeObjectField("schemaTable", recordId.getSchemaTable()); jsonGenerator.writeNumberField("id", recordId.sequenceId()); jsonGenerator.writeEndObject(); }
Example #20
Source File: GraphSONSerializersV1d0.java From tinkerpop with Apache License 2.0 | 5 votes |
private static void serializerVertexProperty(final VertexProperty property, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer, final boolean normalize, final boolean includeLabel) throws IOException { jsonGenerator.writeStartObject(); if (typeSerializer != null) jsonGenerator.writeStringField(GraphSONTokens.CLASS, HashMap.class.getName()); GraphSONUtil.writeWithType(GraphSONTokens.ID, property.id(), jsonGenerator, serializerProvider, typeSerializer); GraphSONUtil.writeWithType(GraphSONTokens.VALUE, property.value(), jsonGenerator, serializerProvider, typeSerializer); if (includeLabel) jsonGenerator.writeStringField(GraphSONTokens.LABEL, property.label()); tryWriteMetaProperties(property, jsonGenerator, serializerProvider, typeSerializer, normalize); jsonGenerator.writeEndObject(); }
Example #21
Source File: SchemaTable.java From sqlg with MIT License | 5 votes |
@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 #22
Source File: GraphSONSerializersV1d0.java From tinkerpop with Apache License 2.0 | 5 votes |
private static void writeMetaProperties(final VertexProperty property, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer, final boolean normalize) throws IOException { jsonGenerator.writeObjectFieldStart(GraphSONTokens.PROPERTIES); if (typeSerializer != null) jsonGenerator.writeStringField(GraphSONTokens.CLASS, HashMap.class.getName()); 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(); GraphSONUtil.writeWithType(metaProperty.key(), metaProperty.value(), jsonGenerator, serializerProvider, typeSerializer); } jsonGenerator.writeEndObject(); }
Example #23
Source File: JavaUtilSerializersV2d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serializeWithType(final Map.Entry entry, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException { typeSerializer.writeTypePrefixForObject(entry, jsonGenerator); ser(entry, jsonGenerator, serializerProvider); typeSerializer.writeTypeSuffixForObject(entry, jsonGenerator); }
Example #24
Source File: JavaTimeSerializersV3d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@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 #25
Source File: JavaTimeSerializersV1d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serializeWithType(final T value, final JsonGenerator gen, final SerializerProvider serializers, final TypeSerializer typeSer) throws IOException { typeSer.writeTypePrefixForObject(value, gen); gen.writeStringField(GraphSONTokens.VALUE, value.toString()); typeSer.writeTypeSuffixForObject(value, gen); }
Example #26
Source File: GraphSONTypeResolverBuilder.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public TypeSerializer buildTypeSerializer(final SerializationConfig config, final JavaType baseType, final Collection<NamedType> subtypes) { final TypeIdResolver idRes = this.idResolver(config, baseType, typeValidator, subtypes, true, false); return version == GraphSONVersion.V2_0 ? new GraphSONTypeSerializerV2d0(idRes, this.getTypeProperty(), typeInfo, valuePropertyName) : new GraphSONTypeSerializerV3d0(idRes, this.getTypeProperty(), typeInfo, valuePropertyName); }
Example #27
Source File: GraphSONUtil.java From tinkerpop with Apache License 2.0 | 5 votes |
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 #28
Source File: CustomId.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serializeWithType(final CustomId customId, 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. jsonGenerator.writeStartObject(); jsonGenerator.writeStringField(GraphSONTokens.CLASS, CustomId.class.getName()); jsonGenerator.writeStringField("cluster", customId.getCluster()); jsonGenerator.writeObjectField("elementId", customId.getElementId()); jsonGenerator.writeEndObject(); }
Example #29
Source File: CustomId.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serializeWithType(final CustomId customId, 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(customId, jsonGenerator); final Map<String, Object> m = new HashMap<>(); m.put("cluster", customId.getCluster()); m.put("elementId", customId.getElementId()); jsonGenerator.writeObject(m); typeSerializer.writeTypeSuffixForScalar(customId, jsonGenerator); }
Example #30
Source File: TinkerIoRegistryV1d0.java From tinkerpop 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(); }