I'm trying to convert the GraphResultSet object to JSON format similar to datastax studio returns. I'm trying to use Graphson. Is there any sample codes convert the result object to JSON?
i tried the following from the tikerpop blueprints but its not working
List<GraphNode> gf=((GraphResultSet) resultSet).all();
Vertex v = (Vertex) gf.get(0).asVertex();
JSONObject json = null;
try {
json = GraphSONUtility.jsonFromElement((Element) v,getElementPropertyKeys((Element) v, false), GraphSONMode.COMPACT);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
I'm getting a GraphResultSet object from dse, It has vertex and edges. I wanted to output in JSON format.
You can't directly cast between com.datastax.driver.dse.graph.DefaultVertex
& com.tinkerpop.blueprints.Element
.
There is GraphSONUtils class (src) in DSE Java driver that should be able to handle these conversions. But because it's in the "internal" package, I expect that changes may happen any time.