$query = $this->getPluginList(); //查詢語句傳回值
$ret_plugin_ls = array();
foreach ($query->result() as $row) { //Object Storage Service
array_push($ret_plugin_ls, $row);
}
echo json_encode($ret_plugin_ls);
以對象形式儲存的json_encode資料(資料來源在上面) 如下:
$json= '[{"id":"1","plugin_name":"\u4e2a\u63a8","plugin_describe":"\u4e2a\u63a8\u63cf\u8ff0","plugin_provider":"\u897f\u6865","plugin_version":"1.0","plugin_upload_date":"2013-08-12 10:52:26","plugin_detail":"0","plugin_expired":"0"},{"id":"2","plugin_name":"213231","plugin_describe":"12123132","plugin_provider":"2123321213","plugin_version":"2.0","plugin_upload_date":"2013-08-11 15:20:55","plugin_detail":"0","plugin_expired":"0"}]';
轉換成數組:
$arrdata = json_decode($json);
foreach ($allplugins as $row)
{
echo $row->id;
echo $row->plugin_name;
}
列印:
1
個推
2
213231
回複討論(解決方案)
樓主想說什麼呢...
本人才疏學淺敬請諒解。
1、以json格式傳送的資料,接受端要轉化(json_decode)一下;
2、以對象格式儲存發送,接收端也只能以對象格式輸出顯示。
樓主想說什麼呢...
他在授業,不是請求解惑