Inserting data using GraphSON

How to insert data into a graph database using GraphSON.

GraphSON is JSON data that defines a vertex with its ID and label, outgoing and incoming edges, and properties.

Procedure

  1. Identify the vertex ID and label.
    {
      "id":{"~label":"author","member_id":35,"community_id":1733329920}, 
    label":"author",

    Each vertex must have an identifier. Generally, a label is defined to denote the type of vertex. In this example, the vertex shown is an author vertex.

  2. Identify the vertex properties.
    "properties":{"gender":[{
         "id":{
           "local_id":"00000000-0000-8084-0000-000000000000",
           "~type":"gender",
           "out_vertex":{"~label":"author","member_id":35,"community_id":1733329920}},
           "value":"F"
        }],
        "name":[{
            "id":{
            "local_id":"00000000-0000-8083-0000-000000000000",
            "~type":"name",
            "out_vertex":{"~label":"author","member_id":35,"community_id":1733329920}},
            "value":"Simone Beck"}]
    }}

    Each property is identified with a name, ID, and value. The example shows the author name name, which has a value of Simone Beck, and gender valued as F.

  3. Add outgoing edges.
     "outE":{
        "authored":[{
          "id":{
            "out_vertex":{"~label":"author","member_id":35,"community_id":1733329920},
            "local_id":"72086b3c-0e6c-11e6-b5e4-0febe4822aa4",
            "in_vertex":{"~label":"book","member_id":52,"community_id":1733329920},
            "~type":"authored"
          },
        "inV":{"~label":"book","member_id":52,"community_id":1733329920}}, {
          "id":{
            "out_vertex":{"~label":"author","member_id":35,"community_id":1733329920},
            "local_id":"72086b32-0e6c-11e6-b5e4-0febe4822aa4",
            "in_vertex":{"~label":"book","member_id":54,"community_id":1733329920},
            "~type":"authored"
          },
        "inV":{"~label":"book","member_id":54,"community_id":1733329920}}]},

    Each edge must have a label and ID. The example shows an authored edge. For an outgoing edge as shown in the example, an incoming vertex, inV, must be identified by vertex identification.

  4. Close and name the GraphSON file, using a suffix of ".json".