Description
Gremlin.Net incorrectly serializes an object of a custom type for GraphSON 3 if it doesn't have a custom serializer for that type. It simply passes the object to its underlying JSON serializer which results in a JSON serialization without any type information.
I think this shouldn't be possible as we always expect types with GraphSON 3 as per the specs:
> GraphSON 3.0 does not have an option to be typeless. Types are always embedded except for strings and boolean values which are inferred from JSON types.
Example code to reproduce:
var xxx = new[] { new XXX { X = 1, Y = 2 }, new XXX { X = 3, Y = 4 } }; var graphSon = writer.WriteObject(xxx); // graphSon = "{"@type":"g:List","@value":[{"X":1,"Y":2},{"X":3,"Y":4}]}"
But the problem doesn't seem to be limited to .NET as the server also successfully responds to a request with such a custom type if it's used in a traversal:
var xxx = new[] { new XXX { X = 1, Y = 2 }, new XXX { X = 3, Y = 4 } }; var result = (List<object>)await g.Inject<object>(xxx).Promise(t => t.ToList()); foreach (var x in result) { foreach (var pair in (Dictionary<object, object>)x) { Console.WriteLine($"{pair.Key}: {pair.Value}"); } } /*… which displays: X: 1 Y: 2 X: 3 Y: 4*/
This was first reported on the janusgraph-users mailing list by billpoole.