无法以 JSON 格式从 gremlin 客户端检索查询结果

Unable to retrieve query result from gremlin client in JSON format

案例
我在 Java 中使用 ResultSet 的提交方法(由 org.apache.tinkerpop:gremlin-driver:3.0.1-incubating dependency 提供)来查询 gremlin 服务器。我需要知道如何配置我的客户端以接收 JSON 格式的响应。

我做了什么
我尝试同时使用 GraphSONMessageSerializerV1d0GraphSONMessageSerializerGremlinV1d0 序列化程序,但响应无效 json.This 是我的 gremlin-server.yaml文件

authentication: {className: 
org.apache.tinkerpop.gremlin.server.auth.AllowAllAuthenticator,
config: null}
channelizer: 
org.apache.tinkerpop.gremlin.server.channel.WebSocketChannelizer
graphs: {graph: src/test/resources/titan-inmemory.properties}
gremlinPool: 8
host: localhost
maxAccumulationBufferComponents: 1024
maxChunkSize: 8192
maxContentLength: 65536
maxHeaderSize: 8192
maxInitialLineLength: 4096
metrics:
 consoleReporter: null
 csvReporter: null
 gangliaReporter: null
 graphiteReporter: null
 jmxReporter: null
 slf4jReporter: {enabled: true, interval: 180000, loggerName: 
org.apache.tinkerpop.gremlin.server.Settings$Slf4jReporterMetrics}
plugins: [aurelius.titan]
port: 8182
processors: []
resultIterationBatchSize: 64
scriptEngines:
gremlin-groovy:
config: null
imports: [java.lang.Math]
scripts: [src/test/resources/generate-asset-plus-locations.groovy]
staticImports: [java.lang.Math.PI]
scriptEvaluationTimeout: 30000
serializedResponseTimeout: 30000
serializers:
 - className: 
   org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0
   config: {useMapperFromGraph: graph}
 - className: 
  org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0
  config: {serializeResultToString: true}
 - className: 
   org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializer
   GremlinV1d0
   config: {useMapperFromGraph: graph}
 - className: 
  org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0
  config: {useMapperFromGraph: graph}
  ssl: {enabled: false, keyCertChainFile: null, keyFile: null, keyPassword: 
   null, trustCertChainFile: null}
  threadPoolBoss: 1
  threadPoolWorker: 1
  writeBufferHighWaterMark: 65536
  writeBufferLowWaterMark: 32768

因此,如果有人可以帮助我配置客户端以接收 JSON 格式的结果,那就太好了!!

要使用 GraphSON 作为序列化格式,您只需将其指定给 Cluster 构建器:

Cluster cluster = Cluster.build().serializer(Serializers.GRAPHSON_V2D0).create();

但是,这不会 return 您可以使用 JSON 的字符串,这毫无价值。它告诉服务器使用 JSON 作为序列化格式,但驱动程序将 JSON 反序列化为对象(地图、列表等)。如果你想要一个实际的 JSON 字符串,那么你应该 return 在你发送到服务器的脚本中。您唯一的其他选择是编写您自己的序列化程序,它总是只保留字符串。