Question: I have a collection of JSON values that has 3 levels:

cluster > segment > node

Where each cluster is made of segments and each segment is made up of nodes. I am trying to figure out how to represent this as a JSON object and I am unsure how to create the structure. 

Each node contains an id and a reference to its segment id and cluster id. I have written up a test object like this:

```
 var customers = [
                     {
                    "cluster" : 
                         {"flights":4, "profit":5245, "clv":2364,
                    "segment" :
                        { "flights":2, "profit":2150, "clv":1564,
                            "node" :
                                    { 'xpos': 1, 'ypos': 2 }// closes node
                        }// closes segment 
                         }//closes cluster
                     },
{
                    "cluster" : 
                         {"flights":4, "profit":5245, "clv":2364,
                    "segment" :
                        { "flights":2, "profit":2150, "clv":1564,
                            "node" :
                                    { 'xpos': 1, 'ypos': 2 }// closes node
                        }// closes segment 
                         }//closes cluster
                     }
];

```

The part that feels a bit flaky is the way segment and node are nested. I am not getting any errors but is this the best way to represent this data?

EDIT:

Thanks for the answers, it definitely pointed me in the right direction as far as tools to use (jsonlint) and get a better understanding of structuring data in json. They're all correct answers which shows me that it was a pretty basic question. Thanks again.

Answer: 
the nature of json you have is perfectly valid (the idea of an object nested in an object) if not syntactically correct (didn't verify that all your commas were in the right place).

however, you dont have what you said you wanted, which is a *collection* of segments in a cluster, and a collection of nodes in a segment.

change it to be 

```
[{
  "cluster": {..,
     "segments": [{    <--- note the array -- you now have a collection
         "name": 'segment1', <- optional, just here to show multiple segments
         "nodes": [{....}] <-- same here
     }, 
     {
         "name": 'segment2',
         "nodes": [{....}]
     }]
  }
}]

```
I think this looks alright for the most part. However, note the following:

1. `JSON key and values should be in double quotes`"`and not single quotes`'`. Look at your`xpos`and`ypos` values to see what I mean. I usually use [JSONLint](http://jsonlint.com/) to ensure that my JSON is valid.
2. You say that `cluster`s have a collection of `segment`s and `segment`s have a collection of `node`s. This might be best represented as arrays.
3. It also looks like you want multiple clusters. That is also best expressed as an array.

So something of the form (greatly exaggerated the indentation, hopefully that will help):

```
{
    "cluster" : [
                    {
                        "flights": 4,
                        "profit": 5245,
                        "clv": 2364,
                        "segment" : [
                                        {
                                            "flights": 2,
                                            "profit": 2150,
                                            "clv": 1564,
                                            "node" : [
                                                        {
                                                            "xpos": 1,
                                                            "ypos": 2 
                                                        }, 
                                                        {
                                                            //node 2
                                                        }
                                                    ] 
                                        }, 
                                        {
                                            //segment 2
                                        }
                                    ] 
                    },
                    {
                        //next cluster
                    }
                ]
}

```