Florian Hockmann created TINKERPOP-2788:
-------------------------------------------
Summary: Gremlin.Net incorrectly serializes custom types without
type information for GraphSON 3
Key: TINKERPOP-2788
URL: https://issues.apache.org/jira/browse/TINKERPOP-2788
Project: TinkerPop
Issue Type: Bug
Components: dotnet, server
Affects Versions: 3.5.4, 3.6.1
Reporter: Florian Hockmann
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|https://tinkerpop.apache.org/docs/current/dev/io/#graphson-3d0]:
> 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:
{code:java}
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}]}" {code}
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:
{code:java}
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*/{code}
This was first reported [on the janusgraph-users mailing
list|https://lists.lfaidata.foundation/g/janusgraph-users/message/6612] by
[~billpoole].
--
This message was sent by Atlassian Jira
(v8.20.10#820010)