gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONSerializersV3.java [234:309]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            tryWriteMetaProperties(property, jsonGenerator, normalize);

            jsonGenerator.writeEndObject();
        }

        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);
                }
            }
        }

        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();
        }
    }

    final static class PathJacksonSerializer extends StdScalarSerializer<Path> {

        public PathJacksonSerializer() {
            super(Path.class);
        }

        @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();
        }
    }

    final static class TreeJacksonSerializer extends StdScalarSerializer<Tree> {

        public TreeJacksonSerializer() {
            super(Tree.class);
        }

        @Override
        public void serialize(final Tree tree, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException, JsonGenerationException {
            jsonGenerator.writeStartArray();
            final Set<Map.Entry<Element, Tree>> set = tree.entrySet();
            for (Map.Entry<Element, Tree> entry : set) {
                jsonGenerator.writeStartObject();
                jsonGenerator.writeObjectField(GraphSONTokens.KEY, entry.getKey());
                jsonGenerator.writeObjectField(GraphSONTokens.VALUE, entry.getValue());
                jsonGenerator.writeEndObject();
            }
            jsonGenerator.writeEndArray();
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONSerializersV4.java [250:325]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            tryWriteMetaProperties(property, jsonGenerator, normalize);

            jsonGenerator.writeEndObject();
        }

        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);
                }
            }
        }

        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();
        }
    }

    final static class PathJacksonSerializer extends StdScalarSerializer<Path> {

        public PathJacksonSerializer() {
            super(Path.class);
        }

        @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();
        }
    }

    final static class TreeJacksonSerializer extends StdScalarSerializer<Tree> {

        public TreeJacksonSerializer() {
            super(Tree.class);
        }

        @Override
        public void serialize(final Tree tree, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException, JsonGenerationException {
            jsonGenerator.writeStartArray();
            final Set<Map.Entry<Element, Tree>> set = tree.entrySet();
            for (Map.Entry<Element, Tree> entry : set) {
                jsonGenerator.writeStartObject();
                jsonGenerator.writeObjectField(GraphSONTokens.KEY, entry.getKey());
                jsonGenerator.writeObjectField(GraphSONTokens.VALUE, entry.getValue());
                jsonGenerator.writeEndObject();
            }
            jsonGenerator.writeEndArray();
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



