Json_Encode : how can I get the json_encoded array to work with Datatable ?

Json_Encode : how can I get the json_encoded array to work with Datatable ?

theyouyoutheyouyou Posts: 12Questions: 0Answers: 0
edited July 2010 in General
Hello,

Here's what I get from the PHP json_encode function :

{"id_parcelle":"974000087_1_1","datesimul":"2009-07-10","nomplante":"R570","dmbaer":"3226.49"},
{"id_parcelle":"974000087_1_2","datesimul":"2009-06-10","nomplante":"R571","dmbaer":"3226.49"}

Any clue for getting this to work with datatables ?

Replies

  • gutzoftergutzofter Posts: 58Questions: 0Answers: 0
    Try jsonlint.com

    maybe this is what you need:
    [code]
    [
    {
    "id_parcelle": "974000087_1_1",
    "datesimul": "2009-07-10",
    "nomplante": "R570",
    "dmbaer": "3226.49"
    },
    {
    "id_parcelle": "974000087_1_2",
    "datesimul": "2009-06-10",
    "nomplante": "R571",
    "dmbaer": "3226.49"
    }
    ]
    [/code]
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Actually - you need to have a 2D array, rather than an array of objects. See: http://datatables.net/plug-ins/server-data-formats for a plug-in which converts the OpenSearch format into a 2D array. You can use something very simialr, just customised for your data.

    Allan
This discussion has been closed.