title: How to access nested JSON data with dynamic variables
body: <p>I am stuck on a issue where i need to access a nested JSON with dynamic variables. This is my JSON:</p>
  
  <pre><code>{
      "Account2": [{
          "accountId": "17467****",
          "containerId": "7454***",
          "path": "accounts\/17467*****\/containers\/7454***",
      }, {
          "accountId": "17467****",
          "containerId": "7519***",
          "path": "accounts\/17467****\/containers\/7519***",
      }],
      "Account 1": [{
          "accountId": "17661****",
          "containerId": "7483***",
          "path": "accounts\/17661****\/containers\/7483***",
      }]
  }
  </code></pre>
  
  <p>Using AngluarJS on front-end i use this to print a table, here i can use the "path" variable to use a href and then make second API call based on url parameters like this:</p>
  
  <pre><code>&lt;td&gt;&lt;a href="/gui/tags/{{v1.path}}"&gt;View Container&lt;/a&gt;&lt;/td&gt;
  </code></pre>
  
  <blockquote>
    <p>v1.path = accounts/17467*****/containers/7454***</p>
  </blockquote>
  
  <p>Now to my problem, i want to send this call before clicking on table to show some data. The problem is that when accessing the JSON that has dynamic variable as you can see: "Account2", "Account1". I cannot use: `$scope.GTMcontainersAccount = response.data.ACCOUNT1;</p>
  
  <p>because "account1" is dynamic and changes from user to user. </p>
  
  <p>Someone has an idea? regEx?</p>
  
  <p><strong>UPDATED:</strong></p>
  
  <p>when i use:</p>
  
  <pre><code> $scope.GTMcontainersAccount = response.data;
                      $scope.keys = Object.keys(response.data);
                      for(n in $scope.keys)
                      {
                         $scope.asim = $scope.keys[n];
                         console.log($scope.asim);
                         console.log(response.data[$scope.asim]);
                      }
  </code></pre>
  
  <p>This gives me this result:</p>
  
  <p><a href="https://i.stack.imgur.com/MMpa4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MMpa4.png" alt="enter image description here"></a></p>
  
  <p>So i have to write like:</p>
  
  <pre><code>console.log(response.data[$scope.asim][0].accountId);
  </code></pre>
  
  <p>But this gives me only row of "account2" not "account1"</p>