title: How to get json object and nested object Property names and values in AngularJs?
body: <p>I have a json object like this</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>{
    "from": {
      "required": false,
      "type": {
        "name": {
          "required": false,
          "type": "String"
        },
        "email": {
          "required": true,
          "type": "String"
        }
      }
    },
    "to": {
      "required": true,
      "type": [
        {
          "name": {
            "required": false,
            "type": "String"
          },
          "email": {
            "required": true,
            "type": "String"
          }
        }
      ]
    },
    "subject": {
      "required": true,
      "type": "String"
    },
    "text": {
      "required": true,
      "type": "String"
    },
    "html": {
      "required": true,
      "type": "String"
    }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>The object contains nested objects, having properties getting set from various services. So, property names are dynamically changed. I want to get property names and respective values. I'd already tried out the following code.</p>
  
  <pre><code> for (var prop in data) {
                  $scope.fieldsInfo.push({ "label": prop, "required":data.hasOwnProperty(prop) });
              }
  </code></pre>
  
  <p>In the above code iam getting property name (from) and required value also , now i want to get nested object property names ( name,email) and also (required,type) values inside the name object. In the above object <code>from</code> contains <code>type</code> is a object so <code>isArray:false</code> and next object <code>to</code> contains <code>type</code> is a array so <code>isArray:true</code> remaining objects <code>type</code> is a string so <code>isArray:false</code>. 
  Output like this</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$scope.fieldsInfo=[];
  
    $scope.fieldsInfo=[
                        { 
                         "label"    :"from",
                         "required" :false,
                         "isArray"  :false,
                         "type"     : [
                                        {
                                          "label"   :"name",
                                          "type"    : "String",
                                          "required": false
                                        }
                                        {
                                          "label"   : "email",
                                          "type"    : "String",
                                          "required": true 
                                        }                     
                                      ]
                        },
                        { 
                         "label"    :"to",
                         "required" :true,
                         "isArray"  :true,
                         "type"     : [
                                        {
                                          "label"   : "name",
                                          "type"    : "String",
                                          "required": false
                                        }
                                        {
                                          "label"   : "email",
                                          "type"    : "String",
                                          "required": true 
                                        }                       
                                      ]
                        },
                        { 
                         "label"    :"subject",
                         "required" :true,
                         "isArray"  :false,
                         "type"     :"String" 
                        },
                        { 
                         "label"    :"text",
                         "required" :true,
                         "isArray"  :false,
                         "type"     :"String" 
                        },
                        { 
                         "label"    :"html",
                         "required" :true,
                         "isArray"  :false,
                         "type"     :"String" 
                        }
                      ]</code></pre>
  </div>
  </div>
  </p>