Codeigniter レスト サーバーを使用して API を作成しています。私のクライアントの 1 つは、次の JSON 配列を API に送信しています
{
"code": "TEST",
"store": "DBNG0024",
"total": "50.00",
"items": [{ "code":"121", "descr":"Pizza 1", "value":"50", "qty":"1", "dept":"1"}]
}
残りのサーバーのドキュメントには、次のようなデータにアクセスできると書かれています。
function client_post()
{
$code = $this->post('code');
$store_code = $this->post('store');
$total = $this->post('total');
$data = array('code' => $this->post('code'), 'store' => $this->post('store'), 'status' => 'invalid', 'value' => '0', 'message' => 'code is invalid');
$this->response($data);
}
これは完全に機能します。今私が抱えている問題は、多次元データ "items": [{ "code":"121", "descr":"Pizza 1", "value":"50", "qty": にアクセスできないことです: "1", "部門":"1"}]
私は次のことを試しました
$items = json_decode($this->post(‘items’)); - Prints nothing
$items = $this->post(‘items’); - prints the word Array
このように投稿データを印刷すると print_r($_POST,true); 以下は印刷されたものです
Array ( [code] => 1234 [store] => 1234 [total] => 1234 [items] => Array )
$items配列データにアクセスする方法を見つけるのを手伝ってくれる人はいますか
前もって感謝します