Java Code Examples for org.apache.tinkerpop.shaded.jackson.core.JsonGenerator#writeFieldName()
The following examples show how to use
org.apache.tinkerpop.shaded.jackson.core.JsonGenerator#writeFieldName() .
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: 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 2
Source File: TinkerIoRegistryV2d0.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: TinkerIoRegistryV3d0.java From tinkerpop 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 4
Source File: TinkerIoRegistryV2d0.java From tinkerpop 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 5
Source File: GraphSONSerializersV3d0.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 6
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(); }
Example 7
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 8
Source File: GraphSONSerializersV2d0.java From tinkerpop with Apache License 2.0 | 5 votes |
private void ser(final Object o, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { if (Element.class.isAssignableFrom(o.getClass())) jsonGenerator.writeFieldName((((Element) o).id()).toString()); else super.serialize(o, jsonGenerator, serializerProvider); }
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 |
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 11
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 12
Source File: GraphSONSerializersV1d0.java From tinkerpop with Apache License 2.0 | 5 votes |
private void ser(final Object o, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { if (Element.class.isAssignableFrom(o.getClass())) jsonGenerator.writeFieldName((((Element) o).id()).toString()); else super.serialize(o, jsonGenerator, serializerProvider); }
Example 13
Source File: GraphSONSerializersV3d0.java From tinkerpop with Apache License 2.0 | 5 votes |
private void ser(final Object o, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { if (Element.class.isAssignableFrom(o.getClass())) jsonGenerator.writeFieldName((((Element) o).id()).toString()); else super.serialize(o, jsonGenerator, serializerProvider); }
Example 14
Source File: HugeGraphSONModule.java From hugegraph with Apache License 2.0 | 5 votes |
private static void writeEntry(JsonGenerator jsonGenerator, Map<HugeKeys, Object> schema) throws IOException { jsonGenerator.writeStartObject(); for (Map.Entry<HugeKeys, Object> entry : schema.entrySet()) { jsonGenerator.writeFieldName(entry.getKey().string()); jsonGenerator.writeObject(entry.getValue()); } jsonGenerator.writeEndObject(); }
Example 15
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 16
Source File: AbstractGraphSONMessageSerializerV2d0.java From tinkerpop with Apache License 2.0 | 5 votes |
public void ser(final ResponseMessage responseMessage, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider, final TypeSerializer typeSerializer) throws IOException { GraphSONUtil.writeStartObject(responseMessage, jsonGenerator, typeSerializer); jsonGenerator.writeStringField(SerTokens.TOKEN_REQUEST, responseMessage.getRequestId() != null ? responseMessage.getRequestId().toString() : null); jsonGenerator.writeFieldName(SerTokens.TOKEN_STATUS); GraphSONUtil.writeStartObject(responseMessage, jsonGenerator, typeSerializer); 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()); GraphSONUtil.writeEndObject(responseMessage, jsonGenerator, typeSerializer); jsonGenerator.writeFieldName(SerTokens.TOKEN_RESULT); GraphSONUtil.writeStartObject(responseMessage, jsonGenerator, typeSerializer); if (null == responseMessage.getResult().getData()){ jsonGenerator.writeNullField(SerTokens.TOKEN_DATA); } else { jsonGenerator.writeFieldName(SerTokens.TOKEN_DATA); final Object result = responseMessage.getResult().getData(); serializerProvider.findTypedValueSerializer(result.getClass(), true, null).serialize(result, jsonGenerator, serializerProvider); } jsonGenerator.writeObjectField(SerTokens.TOKEN_META, responseMessage.getResult().getMeta()); GraphSONUtil.writeEndObject(responseMessage, jsonGenerator, typeSerializer); GraphSONUtil.writeEndObject(responseMessage, jsonGenerator, typeSerializer); }
Example 17
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 18
Source File: TinkerIoRegistryV1d0.java From tinkergraph-gremlin 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 19
Source File: HugeGraphSONModule.java From hugegraph with Apache License 2.0 | 5 votes |
public void writePropertiesField(Map<Id, HugeProperty<?>> properties, JsonGenerator generator, SerializerProvider provider) throws IOException { // Start write properties generator.writeFieldName("properties"); generator.writeStartObject(); for (HugeProperty<?> property : properties.values()) { String key = property.key(); Object val = property.value(); try { generator.writeFieldName(key); if (val != null) { JsonSerializer<Object> serializer = provider.findValueSerializer(val.getClass()); serializer.serialize(val, generator, provider); } else { generator.writeNull(); } } catch (IOException e) { throw new HugeException( "Failed to serialize property(%s: %s) " + "for vertex '%s'", key, val, property.element()); } }; // End wirte properties generator.writeEndObject(); }
Example 20
Source File: HugeGraphSONModule.java From hugegraph with Apache License 2.0 | 5 votes |
public void writeIdField(String fieldName, Id id, JsonGenerator generator) throws IOException { generator.writeFieldName(fieldName); if (id.number()) { generator.writeNumber(id.asLong()); } else { generator.writeString(id.asString()); } }