Recently, I've upgraded Janusgraph to version 0.5.2, it supports the Serializer versions GryoMessageSerializerV3d0, ..V2, ..V1 (Backwards compatibility). In the version3 response for the datatypes strings and array of strings, response format is same. I want the response to be separated.
Current response format(v3):
"@type": "g:Map",
"@value": [
"_id", // string
{
"@type": "g:List",
"@value": [
"id1"
]
},
"names", // array of strings
{
"@type": "g:List",
"@value": [
"Name1", "Name2"
]
},
]
For both datatypes, the response format is {"@type": "g:List",}. My requirement is how can I distinguish the whether datatype is array/string. I can't check for the each key in loop, it won't be proper solution considering there are large number of array datatypes. Is there anything which can be configured at the serialization level. Any other solution to separate the response(Array as array and String as string).
Note: Even for the other serialization versions(v2, v1) there is no differentiation, but response style is different(["id1"], ["Name1", "Name2"]). Everything is array of strings.
Thanks.
We chose to treat arrays as
List
for GraphSON and GraphBinary. You would have to write your own custom serializer plugin to GraphSON. You can see what is involved in developing one by looking at JanusGraph code a bit. You need custom serializer/deserializer instances and a Module to expose them to GraphSON. You can then construct theGraphSONMapper
withaddCustomModule()
. You hand that mapper builder instance to a newGraphSONMessageSerializer
.For the server that means adding your own
IoRegistry
(JanusGraph example [here])4 and adding that to the Gremlin Server configuration file.For the driver that means constructing the
GraphSONMessageSerializer
manually then when constructing theCluster
object with theBuilder
using theserializer(MessageSerializer)
option to supply your instance.As an alternative you could use Gryo which I believe will preserver the array type, but note that: