@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();
        }
GraphSON serializers for graph-based objects such as vertices, edges, properties, and paths. These serializers
present a generalized way to serialize the implementations of core interfaces.

@author Stephen Mallette (http://stephen.genoprime.com)
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONSerializersV3.java