I Am trying to convert the following graphSon Format into a graph instance using the follwing command
graph.io(IoCore.graphson()).reader().create().readGraph(stream, graph);
But while running converting the GRaphSON into graph instance given below
{"id":0,
"label":"buyer",
"outE":
{"email_is":
[{"id":0,"inV":1,
"properties":{"weight":1}
}
]}
,"properties":
{"buyer":
[{
"id":0,"value":"buyer0"
}]
,"age":
[{
"id":1,"value":10}]
}}
{"id":1,
"label":"email",
"inE":
{ "email_is":
[{"id":1,"outV":0,
"properties":{"weight":1}}
]}
,"properties":
{"email":
[{"id":2,
"value":"email0"
}]
}}
I am getting the following error
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:293)
at java.lang.Thread.run(Thread.java:745)Caused by: java.lang.IllegalArgumentException: Invalid vertex provided: null
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:145)
at com.thinkaurelius.titan.graphdb.vertices.AbstractVertex.addEdge(AbstractVertex.java:149)
at com.thinkaurelius.titan.graphdb.vertices.AbstractVertex.addEdge(AbstractVertex.java:23)
at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader.lambda$null$57(GraphSONReader.java:114)
at java.util.Iterator.forEachRemaining(Iterator.java:116)
at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader.lambda$readGraph$58(GraphSONReader.java:108)
at java.util.HashMap$EntrySet.forEach(HashMap.java:1035)
at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader.readGraph(GraphSONReader.java:108)
at pluradj.titan.tinkerpop3.example.JavaExample2.main(JavaExample2.java:50)
... 6 more
Can anyone tell me an easier way to make GRAPHSON file , as it is a very tedious task using StringWriter and JSONWRiter classes.
It doesn't look like there is anything wrong with your format except that you have line breaks where GraphSON's adjacency list requires one vertex per line as so:
In this format it seems to work just fine:
If you want to have "valid" JSON, then you can do this (which is only practical for small graphs):
and then you have to initialize the
GraphSONReader
a little differently and use theunwrapAdjacencyList
setting: