title: Create a Json object in javascript
body: <p>I am in process to validate a form where i need to show certain radio buttons and user need to select them based on some rules,how many number of radio buttons can be created is dynamic so i can not do validation on server side not can write a predefined java-script code for that.</p>
  
  <p>each of the radio buttons will be divided in to groups say <code>required</code> and than further down they can be grouped like <code>center</code>,<code>left</code>, <code>right</code> etc, so from each group user need to select one value, so the structure comes out like this</p>
  
  <pre><code>-Main Group (if block needs to validate based on this e.g if key=required should validate)
    |
    Sub-group (say left, right etc)
     |
     number of radio buttons based on the sub-group
  </code></pre>
  
  <p>So the main group key can be used to decide if validation should be done on that or not and based on the sub-group key i can decide what all values will be there and needs to be validate</p>
  
  <p>i was planning to create a JSON object on page rendering time like</p>
  
  <pre><code>{"required": [
          {"center": "id1,id2,id3"},
          {"left": "id1,id2,id3"}
        ]
    "optional": [
          {"center": "id1,id2,id3"},
          {"left": "id1,id2,id3"}
        ]
  };
  </code></pre>
  
  <p>i am not sure if the structure i am thinking is right and how to create it in java script?
  like i have a external loop for key and than one more loop for the sub-group and finally for the buttons in the sub-group, </p>
  
  <pre><code> for(main group key){
       for(subgroup key){
         for(list of radio button under subgroup key)
  }
    }
  </code></pre>
  
  <p>but not sure how to create a right structure so that i can parse it later with jquery and use that for validation.</p>
  
  <p>Any help in this will really be appreciated.</p>