How to return all subgraphs in a json format?

I'm new to neo4j.

I consider using it for creating links between multiple entities that I currently store in another DB.

Assuming i have a neo4j graph with multiple labels and multiple relationships.

The graph eventually consists of many subgraphs that are not connected between each other.

I want a json representation of all these subgraphs as an input for later loading to another system.

In this scenario I don't need to match on a specific label or property. Just need to export the entire graph to an array of subgraphs and have all the properties from each node.

A possible output would be:

{
  "output": [
    {
      "account1": {
        "prop1": "value1"
      },
      "account2": {
        "prop2": "value2"
      },
      "phone1": {
        "prop3": "value3"
      }
    },
    {
      "account3": {
        "propx": "valuex"
      },
      "account4": {
        "prop6": "value5"
      },
      "phone2": {
        "propaa": "valuedd"
      },
      "website1": {
        "prop_web": "value"
      }
    }
  ]
}

Less "cleaner" outputs will also be fine (meaning, if I get "node" objects).

Can this be achieved in neo4j?

Not without writing your own plugin.

I'm nearly finished with one which does something very similar, which is open source. However, the code is still a bit messy and difficult to adapt. I'm planning to create a simplified fork for people to more easily adapt for purposes such as yours.

That said, any green Java dev who spends a month learning Neo, would be able to strip and adapt my work to suit your purposes.