Java Code Examples for org.apache.tinkerpop.shaded.jackson.core.JsonGenerator#writeArrayFieldStart()
The following examples show how to use
org.apache.tinkerpop.shaded.jackson.core.JsonGenerator#writeArrayFieldStart() .
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: 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 2
Source File: TraversalSerializersV2d0.java From tinkerpop with Apache License 2.0 | 5 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 { 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 3
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(); }