title: DataTables how to use multiple data from json objects
body: <p>so what i'm trying to do is to call some data from a <code>json</code> file to fill my table. But instead of having a lot of <code>json</code> files, i'd like to keep some of the data in a single file. For example, i have 2 types of clients (person and company) and i want to keep them both in the same <code>json</code>, but as different objects, because each one goes in different table.</p>
  
  <p><strong>The problem is:</strong> I can't access the data in the <code>JSON</code> file.</p>
  
  <p>I can use it normally if i use the 2 type of clients in different files (person.json and company.json - This works fine).</p>
  
  <p>I did tried these 2 examples, but none of them worked for me.</p>
  
  <ul>
  <li><a href="https://www.datatables.net/examples/ajax/deep.html" rel="nofollow">https://www.datatables.net/examples/ajax/deep.html</a></li>
  <li><a href="https://www.datatables.net/examples/ajax/objects_subarrays.html" rel="nofollow">https://www.datatables.net/examples/ajax/objects_subarrays.html</a> </li>
  </ul>
  
  <p>So, how can i do get the data from the file? Here is my json and my datatable code:</p>
  
  <pre><code>{
      "clients": {
          "person": [
              {
                  "cd":0,
                  "id":"C-0010",
                  "nm_cliente":"Name AAA",
                  "dt_nasc":"02/11/1990",
                  "info":"Some basic info"
              },
              {
                  "cd":1,
                  "id":"C-0013",
                  "nm_cliente":"Name BBB",
                  "dt_nasc":"02/11/1990",
                  "info":"Some basic info"
              },
              {
                  "cd":2,
                  "id":"C-0017",
                  "nm_cliente":"Name CCC",
                  "dt_nasc":"02/11/1990",
                  "info":"Some basic info"
              }
          ],
          "company": [
              {
                  "cd":0,
                  "id":"C-0032",
                  "nm_cliente":"Name Client",
                  "num_cnpj":"111.222.3333/0001-22",
                  "nm_cidade":"City AAA"
              },
              {
                  "cd":1,
                  "id":"C-0033",
                  "nm_cliente":"Client Name",
                  "num_cnpj":"111.222.3333/0001-22",
                  "nm_cidade":"City BBB"
              },
              {
                  "cd":2,
                  "id":"C-0035",
                  "nm_cliente":"jEmpresa teste",
                  "num_cnpj":"111.222.3333/0001-22",
                  "nm_cidade":"City CCC"
              }
          ]
      }
  }
  </code></pre>
  
  <p>I already used <code>jsonlint.com</code> to verify, and everything is ok with my <code>JSON</code>. And here is how i'm trying to call this data into my tables.</p>
  
  <p>TableA - Client type Person</p>
  
  <pre><code>//rest of the code goes here...
  "aoColumns" : [
      { "mData": "person.id" },
      { "mData": "person.nm_cliente" },
      { "mData": "person.dt_nasc" },
      { "mData": "person.info" }
  ]
  </code></pre>
  
  <p>TableB - Client type Company</p>
  
  <pre><code>//rest of the code goes here...
  "aoColumns" : [
      { "mData": "company.id" },
      { "mData": "company.nm_cliente" },
      { "mData": "company.nm_cnpj" },
      { "mData": "company.nm_cidade" }
  ]
  </code></pre>
  
  <p>I keep getting error like "lenght not defined"</p>
  
  <p>Can anyone help me?</p>