invalid json response

invalid json response

billbpmrbillbpmr Posts: 1Questions: 1Answers: 0

I have the following json (validated on jsonlint.com)

{
"1":{"filename":"100_1273.JPG","uploader":"Administrator","date":"2016-07-19 16:20:57","url":"?a=892456054578e8baa02b633013358079&v=1"},
"2":{"filename":"100_1278.JPG","uploader":"Administrator","date":"2016-07-19 16:20:58","url":"?a=216949462578e8baa087220037447595&v=1"}
}

The data is client side. What is the correct Datasource?

Thanks in advance

Answers

  • NineForty5NineForty5 Posts: 9Questions: 0Answers: 2

    Assuming that 1 & 2 are Id fields, they should be inside the braces:

    [{
        "Id": 1,
        "filename": "100_1273.JPG",
        "uploader": "Administrator",
        "date": "2016-07-19 16:20:57",
        "url": "?a=892456054578e8baa02b633013358079&v=1"
    }, {
        "Id": 2,
        "filename": "100_1278.JPG",
        "uploader": "Administrator",
        "date": "2016-07-19 16:20:58",
        "url": "?a=216949462578e8baa087220037447595&v=1"
    }]
    
  • allanallan Posts: 61,726Questions: 1Answers: 10,110 Site admin

    Yes, DataTables at the time does not support an object as the data source for the rows - it has to be an array of information for the rows. The array can then contain objects for each row, but the outer container must be an array.

    Allan

This discussion has been closed.