Skip to main content
5 de 5
título editado
KeTeMeTo
  • 1k
  • 1
  • 9
  • 21

Error al gestionar un JSON: Requested unknown parameter '0' for row 0, column 0

Buenas tengo un JSON que cojo de la pubg api y lo he transformado para lo que necesito, el json es el siguiente:

{
    "data": [{
        "nombre": "Nomemate",
        "atributo": {
            "assists": 287,
            "bestRankPoint": 4314.65,
            "boosts": 1037,
            "dBNOs": 708,
            "dailyKills": 19,
            "dailyWins": 1,
            "damageDealt": 119668.64,
            "days": 63,
            "headshotKills": 167,
            "heals": 1303,
            "killPoints": 0,
            "kills": 751,
            "longestKill": 453.62796,
            "longestTimeSurvived": 1954.96,
            "losses": 523,
            "maxKillStreaks": 4,
            "mostSurvivalTime": 1954.96,
            "rankPoints": 4314.65,
            "rankPointsTitle": "5-4",
            "revives": 195,
            "rideDistance": 708221.06,
            "roadKills": 0,
            "roundMostKills": 7,
            "roundsPlayed": 573,
            "suicides": 7,
            "swimDistance": 4756.804,
            "teamKills": 10,
            "timeSurvived": 494004.94,
            "top10s": 265,
            "vehicleDestroys": 14,
            "walkDistance": 806560.6,
            "weaponsAcquired": 2594,
            "weeklyKills": 67,
            "weeklyWins": 4,
            "winPoints": 0,
            "wins": 57
        }
    }, {
        "nombre": "KeTeMeTo",
        "atributo": {
            "assists": 56,
            "bestRankPoint": 2828.7388,
            "boosts": 336,
            "dBNOs": 114,
            "dailyKills": 1,
            "dailyWins": 0,
            "damageDealt": 19943.97,
            "days": 34,
            "headshotKills": 41,
            "heals": 436,
            "killPoints": 0,
            "kills": 139,
            "longestKill": 324.68155,
            "longestTimeSurvived": 1899.685,
            "losses": 161,
            "maxKillStreaks": 2,
            "mostSurvivalTime": 1899.685,
            "rankPoints": 2828.7388,
            "rankPointsTitle": "3-1",
            "revives": 59,
            "rideDistance": 288549.62,
            "roadKills": 0,
            "roundMostKills": 5,
            "roundsPlayed": 165,
            "suicides": 4,
            "swimDistance": 1124.9402,
            "teamKills": 4,
            "timeSurvived": 159221.55,
            "top10s": 78,
            "vehicleDestroys": 4,
            "walkDistance": 282959.44,
            "weaponsAcquired": 710,
            "weeklyKills": 1,
            "weeklyWins": 0,
            "winPoints": 0,
            "wins": 8
        }
    }]
}

$(document).ready(function() {
    $('#rank').DataTable( {
        ajax: {
            url: 'table/datos.php',
            type: 'POST',
            dataType: 'json',
            columns :[
                {data: 'nombre'},
                {data: 'atributo.assists'},
                {data: 'atributo.bestRankPoint'},
                {data: 'atributo.boosts'},
                {data: 'atributo.dBNOs'},
                {data: 'atributo.dailyKills'},
                {data: 'atributo.dailyWins'},
                {data: 'atributo.damageDealt'},
                {data: 'atributo.days'},
                {data: 'atributo.headshotKills'},
                {data: 'atributo.heals'},
                {data: 'atributo.killPoints'},
                {data: 'atributo.kills'},
                {data: 'atributo.longesstKill'},
                {data: 'atributo.longestTimeSurvived'},
                {data: 'atributo.losses'},
                {data: 'atributo.maxKillStreaks'},
                {data: 'atributo.mostSurvivalTime'},
                {data: 'atributo.rankPoints'},
                {data: 'atributo.rankPointsTitle'},
                {data: 'atributo.revives'},
                {data: 'atributo.rideDistance'},
                {data: 'atributo.roadKills'},
                {data: 'atributo.roundMostKills'},
                {data: 'atributo.roundsPlayed'},
                {data: 'atributo.suicides'},
                {data: 'atributo.swimDistance'},
                {data: 'atributo.teamKills'},
                {data: 'atributo.timeSurvided'},
                {data: 'atributo.top10s'},
                {data: 'atributo.vehicleDestroys'},
                {data: 'atributo.walkDistance'},
                {data: 'atributo.weaponsAcquired'},
                {data: 'atributo.weeklyKills'},
                {data: 'atributo.weeklyWins'},
                {data: 'atributo.winPoints'},
                {data: 'atributo.wins'},
            ]
        },
    } );



} );
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.5.6/js/dataTables.buttons.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.5.6/js/buttons.print.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.5.6/js/buttons.flash.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
<script src="https://cdn.datatables.net/buttons/1.5.6/js/buttons.html5.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.5.6/js/buttons.print.min.js"></script>
<link href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css" rel="stylesheet">
    <link href="https://cdn.datatables.net/buttons/1.5.6/css/buttons.dataTables.min.css" rel="stylesheet">

<table id="rank" class="display" style="width:100%">
    <thead>
    <tr>
        <th>Asistencias</th>
        <th>BestRankPoint</th>
        <th>Boost</th>
        <th>dBNOs</th>
        <th>dailyKills</th>
        <th>damageDealt</th>
        <th>days</th>
        <th>headshotKills</th>
        <th>heals</th>
        <th>killPoints</th>
        <th>kills</th>
        <th>longestKill</th>
        <th>longestTimeSurvived</th>
        <th>losses</th>
        <th>maxKillStreaks</th>
        <th>mostSurvivalTime</th>
        <th>rankPoints</th>
        <th>rankPointsTitle</th>
        <th>revives</th>
        <th>rideDistance</th>
        <th>roadKills</th>
        <th>roundMostKills</th>
        <th>roundsPlayed</th>
        <th>suicides</th>
        <th>swimDistance</th>
        <th>teamKills</th>
        <th>timeSurvived</th>
        <th>top10s</th>
        <th>vehicleDestroys</th>
        <th>walkDistance</th>
        <th>weaponsAcquired</th>
        <th>weeklyKills</th>
        <th>weeklyWins</th>
        <th>winPoints</th>
        <th>wins</th>
    </tr>
    </thead>
    <tfoot>
    <tr>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
    </tr>
    </tfoot>
</table>
este es el error introducir la descripción de la imagen aquí

el caso es que quiero que me muestre un listado con los usuarios y estos resultados, y me da error, Cuando consiga que los datos se muestren correctamente también querría hacer algunos cálculos antes de mostrar los datos, esto seria posible también?

KeTeMeTo
  • 1k
  • 1
  • 9
  • 21