gremlin - JanusGraph 3.x graphson 导入在美化 json 上失败
问题描述
将美化的 json/graphson 导入 JanusGraph 是否有其他人有此问题?
完全相同但未美化的文件(无回车、制表符、空格)将完美导入,但如果美化它会失败并出现以下错误:
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]
etc - 所以这绝对是文件中的空格问题。
版本 3.x
当然,这不是理想的行为。无论是用空格美化还是缩小,json 都应该同样有效。
解决方案
需要注意的是,GraphSON 有两种形式。在一种形式中,整个文件不是单个 JSON 文档,而是每一行。每条线代表一个顶点的邻接表。
这是默认的 GraphSON 格式,它是为流式设计的,因此文件可以很容易地被分解以进行多线程操作。另一种形式是包含所有顶点和所有边的单个 JSON 文档。
格式记录在这里
推荐阅读
- sql - 删除 SQL 中的尾随子字符串
- powershell - PowerShell If 语句:IF 等于多个特定文本
- java - Vaadin:过滤器的菊花链?
- angular - docker化我的角度应用程序时如何保持实时重新加载
- javascript - 如何在单击一次按钮时触发两个功能
- algorithm - 有人能解释一下为什么双端队列用于滑动窗口算法吗?
- php - laravel join 和 where 条件在两个带有分页的表上
- node.js - 如果没有结果,猫鼬会忽略 findOne 上的回调
- r - 从多列中包含变量的杂乱数据创建新变量
- azure-devops - Azure Devops - 计划代理更新