json将数据编码为数据表

时间:2014-10-10 19:35:21

标签: php jquery json datatable

我使用'服务器端'版本的数据表来获得这个json编码数据。 但是如何在数据表中抛出此值,以便我的数据可以以表格格式列出?

{"sEcho":0,"iTotalRecords":"40","iTotalDisplayRecords":"40","aaData":[["test@test.com","5656565","656565"],["test@test.com","5656565","656565"],["test@test.com","5656565","656565"],["test@test.com","Greater Noida","201308"],["test@test.com","Greater Noida","201308"],["test@test.com","Greater Noida","201308"],["test@test.com","656","56"],["test@test.com","656","56"],["test@test.com","656","56"],["test@test.com","Lucknow","226005"],["test@test.com","Lucknow","226005"],["test@test.com","Lucknow","226005"],["test@test.com","Greater Noida","201308"],["test@test.com","Greater Noida","201308"],["test@test.com","Greater Noida","201308"],["test@test.com","Lucknow","226005"],["test@test.com","Lucknow","226005"],["test@test.com","Lucknow","226005"],["test@test.com","Lucknow","226005"],["test@test.com","Lucknow","226005"],["test@test.com","Lucknow","226005"],["test@test.com","Lucknow","226005"],["test@test.com","56565","56565"],["test@test.com","Greater Noida","201308"],["test@test.com","Greater Noida","201308"],["rahul_mishra@gmail.com","Greater Noida","201308"],["rahul_mishra@gmail.com","Greater Noida","201308"],["rahul_mishra@gmail.com","Lucknow","226005"],["rahul_mishra@gmail.com","Lucknow","226005"],["rahul_mishra@gmail.com","ko","koko"],["rahul_mishra@gmail.com","ko","koko"],["rahul_mishra@gmail.com","Greater Noida","201308"],["test@test.com","Lucknow","226005"],["znet@gmail.com","o","ok"],["znet@gmail.com","TA","TA"],["znet@gmail.com","Lucknow","226012"],["znet@gmail.com","Lucknow","226012"],["znet@gmail.com","Lucknow","226012"],["test@test.com","o","ok"],["test@test.com","o","ok"]]}

2 个答案:

答案 0 :(得分:0)

$obj = json_decode($json); 

将使用您的数据

创建一个对象

你也可以创建一个数组但是使用true作为第二个参数

$array= json_decode($json, true); 

答案 1 :(得分:0)

您需要通过AJAX加载它。查看jQuery DataTables站点上的示例。

http://www.datatables.net/examples/server_side/object_data.html

您将拥有输出所发布数据的服务器端脚本。你将有一些JS对服务器端脚本进行AJAX调用。这将处理将数据放入表格。