Closed provCristianMaluenda closed 5 years ago
I'm honestly not sure, even trying to dig into this online is not leading to any real answers. I'm not sure how the GraphSON serializer is supposed to serialize this result for g:Map
(from what I can tell is pretty new serialization type supported). In this library we are using the application/vnd.gremlin-v3.0+json
mime-type and the query Result is a json.RawMessage
, as this client isn't trying to interpret or parse the results into a go typed struct, we are leaving that up to the caller.
I have noticed though if you just get a vertex type back with properties, you get a map in @value
. For example using:
g.addV('x').property(id, '1234').
property('timestamp', '2018-07-01T13:37:45-05:00').
property('source', 'tree').
as('x').
addV('y').property(id, '2145').
property('timestamp', '2018-07-01T13:37:45-05:00').
property('source', 'tree').
as('y').
addE('e').
from('x').
to('y')
g.V('1234')
Returns
{
"@type":"g:List",
"@value":[
{
"@type":"g:Vertex",
"@value":{
"id":{
"@type":"g:Int64",
"@value":1234
},
"label":"x"
}
}
]
}
However, the little bit of documentation I've found does indicate this is the expected json output for g:Map
types.
See: https://tinkerpop.apache.org/docs/3.3.3/dev/io/#_map
{
"@type":"g:Map",
"@value":[
{
"@type":"g:Date",
"@value":1481750076295
},
"red",
{
"@type":"g:List",
"@value":[
{
"@type":"g:Int32",
"@value":1
},
{
"@type":"g:Int32",
"@value":2
},
{
"@type":"g:Int32",
"@value":3
}
]
},
{
"@type":"g:Date",
"@value":1481750076295
},
"test",
{
"@type":"g:Int32",
"@value":123
}
]
}
Which still seems a bit weird, although the example in the document confirms it is an array or list of key & values.
Thanks for your answer. I missed the documentation where Tinkerpop defined a "map". It is not the best representation for a map, but I understand the idea to support objects as keys. :)
No problem, it isn't the easiest documentation to find / look up when investigating problems. 😢
Hi, I don't know if it is an issue or I am doing something wrong. I am trying to retrieve a map with values from my Graph DB. I am using Gremlin Server for developing. Using the Gremlin console, I get this:
But, when I use gremtune I have this json:
Why is a
g:Map
represented as a List instead of a real map?Thanks.