0

Does anyone else have this problem importing prettified json/graphson to JanusGraph?

Exactly the same file but not prettified (no carriage returns, tabs, whitespace) will import perfectly but if prettified it fails with the following error:

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]

Note, editing the file to remove the first line break manually and the error message changes to ... at [Source: (ByteArrayInputStream); line: 1, column: 12] etc - so it is definitely an issue with whitespace in the file.

Version 3.x

Surely this is not desired behaviour. json should work the same whether prettified with whitespace or minified.

julianhatwell
  • 1,074
  • 1
  • 8
  • 17
  • Something to be aware of is that there are two forms of GraphSON. In one form, the entire file is not a single JSON document, instead each line is. Each line represents the adjacency list for a vertex. That is the default GraphSON format and it is designed that way for streaming. Does your file conform to this format? Check here for more information. http://tinkerpop.apache.org/docs/3.4.1/dev/io/#graphson – Kelvin Lawrence Apr 01 '21 at 14:58
  • Thanks. I was using the adjacency list graphSON. I was hoping to derive valid files programmatically but I can see now that this is not really feasible for anything other than very simple graphs. – julianhatwell Apr 09 '21 at 13:18
  • I added an answer in case others have similar questions. – Kelvin Lawrence Apr 11 '21 at 12:12

1 Answers1

1

Something to be aware of is that there are two forms of GraphSON. In one form, the entire file is not a single JSON document, instead each line is. Each line represents the adjacency list for a vertex.

That is the default GraphSON format and it is designed that way for streaming and so that the file can easily be broken up for multi-threaded operations. The other form is a single JSON document that contains all the vertices and then all the edges.

The formats are documented here

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

Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38