简体   繁体   中英

Embedded Neo4j Java Node & Relationship Objects to JSON

Am using Neo4j 2.0.1 as Embedded db in java application. Querying in java and getting Nodes and Relationship objects. How can we convert this to JSON format ? So that it will be fed to d3.js for visualization. Is there any Neo4j Java API methods exists ?

You could create domain entities from your nodes and annotate them with Jackson annotations. Converting a pojo to JSON is as easy as

ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
String json = ow.writeValueAsString(object);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM