private void writeProperties(final Vertex vertex, final JsonGenerator jsonGenerator) throws IOException {
            if (vertex.keys().size() == 0)
                return;
            jsonGenerator.writeFieldName(GraphSONTokens.PROPERTIES);
            jsonGenerator.writeStartObject();

            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.writeFieldName(key);

                    jsonGenerator.writeStartArray();
                    while (vertexProperties.hasNext()) {
                        jsonGenerator.writeObject(vertexProperties.next());
                    }
                    jsonGenerator.writeEndArray();
                }
            }

            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/GraphSONSerializersV2.java