JSFiddle - React, Tailwind, and code Playground

by Rafael Boschini

HTML

<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="//cdn.datatables.net/1.10.10/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" href="//cdn.datatables.net/1.10.10/css/jquery.dataTables.min.css">
<table class="table table-bordered">
  <thead>
  </thead>
</table>

JavaScript

$(document).ready(function() {

  var json = '[ {  "Nome": "Felipe",  "Data": "null",  "Tipo": "Normal",  "RG": "123456798"}, {  "Nome": "Felipe2", "Data": "null", "Tipo": "Normal", "RG": "123456798"}, { "Nome": "Felipe3", "Data": "null", "Tipo": "Normal", "RG": "123456798"}]';
  
  var column_names = []; //Array com confi das colunas
  var jsonObj = JSON.parse(json); //Parse no obj json, facilita o manuseio
  
  //Verifica se tem registro, para nao caga tudo
  if(jsonObj.length>0){
  
    //Monta array de colunas
	  $.each(Object.keys(jsonObj[0]),function(idx,obj){
      column_names.push({"sTitle": obj, "mData":obj});
    });
    
    $('.table').DataTable({
      "aaData": jsonObj,
      "aoColumns":column_names
    });

  }
    
});