I am not very experienced in this so need help.I need following things to be done :  

1. Want to traverse a folder structure in a content management repository.  

2. Want to create JSON Object of the folder in child-node form.  

3. Json data will be used to create tree using jQuery

Json format:

```
var data = [
        {
          text: "Parent 1",
          nodes: [
            {
              text: "Child 1",
              nodes: [
                {
                  text: "Grandchild 1"
                },
                {
                  text: "Grandchild 2"
                }
              ]
            },
            {
              text: "Child 2"
            }
          ]
        },
        {
          text: "Parent 2"
        },
        {
          text: "Parent 3"
        },
        {
          text: "Parent 4"
        },
        {
          text: "Parent 5"
        }
      ];

```

My Java method is like this:

```
public static void displayIt(File node){

    System.out.println(node.getAbsoluteFile());

    if(node.isDirectory()){
        String[] subNote = node.list();
        for(String filename : subNote){
            displayIt(new File(node, filename));
        }
    }

}

```

I am Struggling to frame strategy to create JSON object and Array to depict this.

Please can you help me.