Github user okram commented on a diff in the pull request:

    https://github.com/apache/tinkerpop/pull/499#discussion_r88914949
  
    --- Diff: 
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONSerializersV2d0.java
 ---
    @@ -175,8 +177,30 @@ public PropertyJacksonSerializer() {
             public void serialize(final Property property, final JsonGenerator 
jsonGenerator, final SerializerProvider serializerProvider)
                     throws IOException {
                 jsonGenerator.writeStartObject();
    -            jsonGenerator.writeObjectField(GraphSONTokens.KEY, 
property.key());
    +            jsonGenerator.writeStringField(GraphSONTokens.KEY, 
property.key());
                 jsonGenerator.writeObjectField(GraphSONTokens.VALUE, 
property.value());
    +            if (property.element() instanceof VertexProperty) {
    +                VertexProperty vertexProperty = (VertexProperty) 
property.element();
    +                
jsonGenerator.writeObjectFieldStart(GraphSONTokens.ELEMENT);
    +                jsonGenerator.writeStringField(GraphSONTokens.VALUETYPE, 
"g:VertexProperty");
    +                
jsonGenerator.writeObjectFieldStart(GraphSONTokens.VALUEPROP);
    +                jsonGenerator.writeObjectField(GraphSONTokens.ID, 
vertexProperty.id());
    +                jsonGenerator.writeStringField(GraphSONTokens.LABEL, 
vertexProperty.label());
    +                jsonGenerator.writeObjectField(GraphSONTokens.VERTEX, 
vertexProperty.element().id());
    +                jsonGenerator.writeEndObject();
    +                jsonGenerator.writeEndObject();
    +            } else if (property.element() instanceof Edge) {
    +                Edge edge = (Edge) property.element();
    +                
jsonGenerator.writeObjectFieldStart(GraphSONTokens.ELEMENT);
    +                jsonGenerator.writeStringField(GraphSONTokens.VALUETYPE, 
"g:Edge");
    --- End diff --
    
    You can't always expect `outVLabel` and `inVLabel` to exist. Think about 
`ReferenceEdge`. It would be too expensive to always include such information. 
The most important think about the serialization is "can it be attached?" The 
way GraphSON 2.0 was designed, this was not the case. How do you attach a 
property? an vertex property? Finally, given the attach requirements of an 
edge, you have the problem of:
    
    property -> edge -> vertex (which vertex -- in or out?) ...  
    
    The amount of data required to attach a property would be pretty nasty. 
Hence, the "reference" serialization is smaller.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to