here is my php code
function GetTransactionList($data)
{
// DB transaction
$records = array();
while($row = mysql_fetch_array($result))
array_push($records, $row);
echo json_encode(array("IsError" => false, "Records" => $records));
}
this is my json response in ajax call from php
{
IsError:false,
Records:[
{0:1,
1:1000,
2:0,
3:"Peacock India trial payment",
4:"2013-08-03",
5:1,
TransactionID:1,
Credit:1000,
Debit:0,
Reason:"Peacock India trial payment",
TransactionDate:"2013-08-03",
TransactionByUserID:1
}]
}
here I got my result but json_encode() method encodes each row twice first it sets values by index=>value pair and second time it encodes by column_name=>value pair. I want to know why it happens? Is there any way to reduce this double work.? I want json response only as following way
{
IsError:false,
Records:[
{TransactionID:1,
Credit:1000,
Debit:0,
Reason:"Peacock India trial payment",
TransactionDate:"2013-08-03",
TransactionByUserID:1
}]
}