Is this a valid JSON format for Datatables ?

Is this a valid JSON format for Datatables ?

abiieezabiieez Posts: 8Questions: 2Answers: 0
edited October 2012 in General
[code]
{
"iTotalDisplayRecords": 11,
"iTotalRecords": 11,
"aaData": "[{\"creationTime\":0,\"enabled\":true,\"id\":1,\"loginDuration\":0,\"online\":false,\"password\":\"kijang\",\"userName\":\"abiieez\"},{\"creationTime\":0,\"enabled\":false,\"id\":105,\"loginDuration\":0,\"online\":false,\"password\":\"asdasd\",\"userName\":\"asd1212123\"},{\"creationTime\":0,\"enabled\":false,\"id\":106,\"loginDuration\":0,\"online\":false,\"password\":\"asdsdasd\",\"userName\":\"asdasd23123\"},{\"creationTime\":0,\"enabled\":false,\"id\":107,\"loginDuration\":0,\"online\":false,\"password\":\"asdsdasd\",\"userName\":\"asdasd23123\"},{\"creationTime\":0,\"enabled\":false,\"id\":108,\"loginDuration\":0,\"online\":false,\"password\":\"anak jalanan\",\"userName\":\"alibaba90\"},{\"creationTime\":1351338218227,\"enabled\":false,\"id\":109,\"loginDuration\":0,\"online\":false,\"password\":\"asdasdasda\",\"userName\":\"asdasdasda\"},{\"creationTime\":1351338263527,\"enabled\":false,\"id\":110,\"loginDuration\":0,\"online\":false,\"password\":\"asdasdasda\",\"userName\":\"asdasdasda\"},{\"creationTime\":1351338265078,\"enabled\":false,\"id\":111,\"loginDuration\":0,\"online\":false,\"password\":\"asdasdasda\",\"userName\":\"asdasdasda\"},{\"creationTime\":1351338266329,\"enabled\":false,\"id\":112,\"loginDuration\":0,\"online\":false,\"password\":\"asdasdasda\",\"userName\":\"asdasdasda\"},{\"creationTime\":1351338267247,\"enabled\":false,\"id\":113,\"loginDuration\":0,\"online\":false,\"password\":\"asdasdasda\",\"userName\":\"asdasdasda\"}]",
"sEcho": "1"
}
[/code]

I asked this because of the " symbol before the [ and after ]. Also there is a backslash "\" before property name.

Replies

  • TheSisbTheSisb Posts: 18Questions: 0Answers: 0
    edited October 2012
    Afaik it should at least pass JSON lint: http://jsonlint.com/
    Yours does not.

    So you would need to get it as a string, remove the slashes, and parse it on the client side to make yours work I think.
  • abiieezabiieez Posts: 8Questions: 2Answers: 0
    That page says its valid JSON. So, is this valid then ?
  • abiieezabiieez Posts: 8Questions: 2Answers: 0
    edited October 2012
    removing slashes does not let it pass JSON Lint. Should I remove the " before the [ and ] ?
  • abiieezabiieez Posts: 8Questions: 2Answers: 0
    okay it works now after I removed the ". Thanks
This discussion has been closed.