JanusGraph 3.x graphson 导入在美化 json 上失败

JanusGraph 3.x graphson import fails on prettified json

其他人在将美化 json/graphson 导入 JanusGraph 时遇到这个问题吗?

完全相同但未美化的文件(无回车 returns、制表符、空格)将完美导入,但如果美化它会失败并出现以下错误:

graph.io(graphson()).readGraph("data/tgraph2.json")

Could not deserialize the JSON value as required. Nested exception: java.lang.InstantiationException: Cannot deserialize the value with the detected type contained in the JSON ('tinker:graph') to the type specified in parameter to the object mapper (class java.util.LinkedHashMap). Those types are incompatible. at [Source: (ByteArrayInputStream); line: 1, column: 3]

请注意,编辑文件以手动删除第一个换行符并且错误消息更改为 ... at [Source: (ByteArrayInputStream); line: 1, column: 12] 等 - 因此这肯定是文件中的空格问题。

版本3.x

这当然不是我们想要的行为。 json 无论是用空格美化还是缩小,都应该工作相同。

需要注意的是,GraphSON 有两种形式。在一种形式中,整个文件不是单个 JSON 文档,而是每一行。每条线代表一个顶点的邻接表。

这是默认的 GraphSON 格式,它是为流式传输而设计的,因此文件可以很容易地分解为多线程操作。另一种形式是单个 JSON 文档,其中包含所有顶点,然后是所有边。

格式记录在此处

http://tinkerpop.apache.org/docs/3.4.1/dev/io/#graphson