Trouble loading json into list

I’m having trouble loading a JSON result into a list, but don’t know why.

I’ve tried removing the initial “accountdata:”, but with still no luck.

Anyone know why?

JSON

{accountdata:[{"id":"1","name":"Mr Admin","dob":null,"gender":"Male","userid":"dhtmlx","pwd":"*94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29"},{"id":"14","name":"Graham Simmons","dob":null,"gender":"Male","userid":"poo","pwd":"*95AAD6ED425D05910F0CB188708EB68083F4104C"}]}

Using this …

view: "list", id: "listAccounts", url: "accounts.php", datatype: "json", scroll: true, select: true, template: "#name#, #gender#, #userid#", select: true, type: { width: "auto" }

Expected data format is

[{"id":"1","name":"Mr Admin","dob":null,"gender":"Male","userid":"dhtmlx","pwd":"*94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29"},{"id":"14","name":"Graham Simmons","dob":null,"gender":"Male","userid":"poo","pwd":"*95AAD6ED425D05910F0CB188708EB68083F4104C"}]

If you can’t change format of data you can use custom loading as

dhx.ajax("accounts.php", function(text,xml){
    var data = dhx.DataDriver.json.toObject(text,xml);
    $$('listAccounts').parse(data.accountdata);
});

Also, it possible to implement custom loading data type, if you are using similar format in multiple places.

I’ve changed the expected data format and it works :stuck_out_tongue: I thought it had to be valid JSON hence the {} around the data.

I like your other solution which I shall keep handy.

Many thanks for your great support :mrgreen: