How to get data from nested array?

How to get data from nested array?

stereomaniacstereomaniac Posts: 3Questions: 3Answers: 0

I used to download data from a json file in this format:

{
    "data": [
        ["n/a","668","01.11.2021 14:16:20", ... ],
        ["n/a","670","05.11.2021 23:23:54", ...]
    ]
}

...
        "ajax": "first.json",
        columns: [ 
            { data: 0 },
            { data: 1 }
...

And everythig was ok

But now format of my json was changed:

{
    "data": {
        "deals": [["n/a", "718", "30/11/2021 21:46:14"], ["", "718", "30/11/2021 21:46:14"], ... ], 
        "stops": [["07/10/2021 21:48:28", "BTCUSDT"], ["07/10/2021 21:48:28", "BTCUSDT"], ... ] 
    }
}

And I try to get data like this and get "No data available in table":

...
        "ajax": "first.json",
        columns: [ 
            { data: 'deals.0' },
            { data: 'deals.1' }
...

How can I get data from new format of json to my table?

Answers

  • kthorngrenkthorngren Posts: 21,458Questions: 26Answers: 4,975

    If all you want is deals use ajax.dataSrc to point Datatables at this property. For example:

    "ajax": {
      url: "first.json",
      dataSrc: "data.deals"
    },
    

    Kevin

Sign In or Register to comment.