我正在使用 Json 通过 webServices 检索信息。我有一个关于 PHP 的文件来实现它,但 O/P 格式不同。
$sql=mysql_query("select phone1 from xxx where id='".$amp."'");
$response = array();
while($row=mysql_fetch_array($sql))
{
// print_r($row);
$sql_query=mysql_query("select x,y,z from tblRepairQueue where phoneNo='".$row['phone1']."'");
while($row1=mysql_fetch_array($sql_query)){
$ackNo=$row1['ackNo'];
$repairStatus=$row1['repairStatus'];
$savedAt=$row1['savedAt'];
$response[]=array("ackNo"=>"$ackNo","repairStatus"=>"$repairStatus","savedAt"=>"$savedAt");
}}
print json_encode($response);
实际上我在IOS上使用它来解码使用
NSMutableDictionary *userDetails = [NSJSONSerialization JSONObjectWithData:returnData
options:0 error:nil];
我得到的 O/p
NSLog(@"%@", userDetails);
(
{
ackNo = "21031221201377 ";
repairStatus = "Closed and Complete";
savedAt = "0000-00-00 00:00:00";
}
)
我期待就像
[{}, {}]
[
{
ackNo = "21031221201377 ";
repairStatus = "Closed and Complete";
savedAt = "0000-00-00 00:00:00";
}
]
如何实现,我对 PHP 了解不多。如果有人提出建议,非常感谢。