我有兩個問題:正常JSON到GraphSON格式
我在哪裏可以找到真正的GraphSON文件的基本格式,即保證被小鬼控制檯加載成功?我試圖將一個JSON(大約10-20個字段)轉換爲另一個可以由gremlin查詢的文件,但是我實際上找不到任何有關graphson格式保留的字段的相關信息,或者我應該如何處理這些ID等我出口他們提供的現代圖,它甚至不是一個有效的JSON(多個JSON根元素),但JSON的列表[1]我還看到像outE,inE字段...這些字段是我手動必須創建?
如果我能夠創建JSON,我在哪裏告訴服務器在我啓動時將其加載爲基本圖形?在配置文件或腳本中?
謝謝! 阿德里安
[1] https://pastebin.com/drwXhg5k
{"id":1,"label":"person","outE":{"created":[{"id":9,"inV":3,"properties":{"weight":0.4}}],"knows":[{"id":7,"inV":2,"properties":{"weight":0.5}},{"id":8,"inV":4,"properties":{"weight":1.0}}]},"properties":{"name":[{"id":0,"value":"marko"}],"age":[{"id":1,"value":29}]}}
{"id":2,"label":"person","inE":{"knows":[{"id":7,"outV":1,"properties":{"weight":0.5}}]},"properties":{"name":[{"id":2,"value":"vadas"}],"age":[{"id":3,"value":27}]}}
{"id":3,"label":"software","inE":{"created":[{"id":9,"outV":1,"properties":{"weight":0.4}},{"id":11,"outV":4,"properties":{"weight":0.4}},{"id":12,"outV":6,"properties":{"weight":0.2}}]},"properties":{"name":[{"id":4,"value":"lop"}],"lang":[{"id":5,"value":"java"}]}}
{"id":4,"label":"person","inE":{"knows":[{"id":8,"outV":1,"properties":{"weight":1.0}}]},"outE":{"created":[{"id":10,"inV":5,"properties":{"weight":1.0}},{"id":11,"inV":3,"properties":{"weight":0.4}}]},"properties":{"name":[{"id":6,"value":"josh"}],"age":[{"id":7,"value":32}]}}
{"id":5,"label":"software","inE":{"created":[{"id":10,"outV":4,"properties":{"weight":1.0}}]},"properties":{"name":[{"id":8,"value":"ripple"}],"lang":[{"id":9,"value":"java"}]}}
{"id":6,"label":"person","outE":{"created":[{"id":12,"inV":3,"properties":{"weight":0.2}}]},"properties":{"name":[{"id":10,"value":"peter"}],"age":[{"id":11,"value":35}]}}
我應該如何輕鬆地將普通JSON轉換爲可以稍後加載和使用的GraphJSON? (我使用TinkerPop,是的)。 順便說一句,什麼是「wrapAdjacencyList」選項,我在哪裏設置它?我現在在控制檯中工作,稍後我將使用JavaScript。 – Adi
查看javadoc中的構建器:http://tinkerpop.apache.org/javadocs/current/core/org/apache/tinkerpop/gremlin/structure/io/graphson/package-summary.html用於'wrapAdjacencyList'選項。不知道這是否回答你所有的問題 - 我不知道你的意思是「輕鬆地將普通的JSON轉換爲GraphJSON」。 –
但是,您如何在控制檯中實際使用wrapAdjacencyList?我嘗試了 「graph.io(IoCore.graphson())。wrapAdjacencyList(」true「)。writeGraph(「tinkerpop-modern.json」)「但我收到以下錯誤:沒有方法的簽名:org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONIo.wrapAdjacencyList()適用於參數類型:(java .lang.String)values:[true] – Adi