Single Object json to rows with key as column1 and value as col2

Single Object json to rows with key as column1 and value as col2

babablacksheepbabablacksheep Posts: 41Questions: 23Answers: 0
edited March 2014 in DataTables 1.9
Hello,
Is it possible with datatables to convert a single object json returned from server to rows of a table with key being column1 and value as column2.

Single Object Json from server:
[code]
{"data":"abc","name":"Diago","Age":23}
[/code]

Table with 2 columns , col1 key, col2: value
[code]
Sample Table Out Put with key:value pair as row
----------------------
| key | value |
----------------------
| data | abc |
| name | Diago |
| Age | 23 |
----------------------
[/code]

Replies

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    Currently no. The rows in the table must be an array - so you would need to use jQuery's map function, or something similar, to convert from your object to an array. The elements in the array can be objects or arrays, but the rows container must be an array.

    Allan
  • babablacksheepbabablacksheep Posts: 41Questions: 23Answers: 0
    Ok.Thank you.
This discussion has been closed.