Exporting current DB to JSON

Hey, We want to export the current DB to a JSON file. This is used for small scale copy of the DB that includes a small number of users that can be used for unit tests. This does not use any product (e.g. Neptune) but just plain Tinkerpop server/client. I used to export it using Graphson: graph.io(graphson()).writeGraph("data/defaultDB.json"); However, since there are some vertices that are too big (and by that I mean that they have a lot of edges), longer lines are trimmed with a .. at the end, essentially breaking the JSON file. Even if you fix the formatting, there is still omitted information. Is there a better way to do it for small-medium sized DBs with complicated vertices and edges?
4 Replies
kelvinl2816
kelvinl2816•2y ago
TinkerPop has an option to export the entire graph on close. I'm not 100% sure if using that will help. I posted the steps here somewhere the other day. I'll try to find them and copy paste here as well.
configuration = new org.apache.commons.configuration.BaseConfiguration()
configuration.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_LOCATION, 'test.json')
configuration.setProperty(Graph.GRAPH, TinkerGraph.class.getName())
configuration.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_FORMAT, 'graphson')
graph = TinkerGraph.open(configuration)
g=graph.traversal()
g.addV('test')
graph.close()
configuration = new org.apache.commons.configuration.BaseConfiguration()
configuration.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_LOCATION, 'test.json')
configuration.setProperty(Graph.GRAPH, TinkerGraph.class.getName())
configuration.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_FORMAT, 'graphson')
graph = TinkerGraph.open(configuration)
g=graph.traversal()
g.addV('test')
graph.close()
Shush
ShushOP•2y ago
Thanks! I will try it today at work. Do you know if this circumvents the trimming issue when a vertex has too many edges and properties? Regardless, I will test.
kelvinl2816
kelvinl2816•2y ago
I'm not sure on the "trimming" I have not observed that. It is supposed to be the entire graph in a form that is re-loadable. The trimming I thought was only when you print the results to the screen.
Shush
ShushOP•2y ago
Understood. Thanks. I was not able to check today, been in a ton of meetings. Hopefully tomorrow would be calmer in that regard 😅
Want results from more Discord servers?
Add your server