I'm using Codeigniter rest server to create an api. one of my clients is sending the following JSON array to my api
{
"code": "TEST",
"store": "DBNG0024",
"total": "50.00",
"items": [{ "code":"121", "descr":"Pizza 1", "value":"50", "qty":"1", "dept":"1"}]
}
In the rest server documentation is says you can access the data like:
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);
}
This works perfectly. Now the problem I'm having is that I cant access the multidimensional data "items": [{ "code":"121", "descr":"Pizza 1", "value":"50", "qty":"1", "dept":"1"}]
I have tried the following
$items = json_decode($this->post(‘items’)); - Prints nothing
$items = $this->post(‘items’); - prints the word Array
if I print the post data like this print_r($_POST,true); the below is what is printed
Array ( [code] => 1234 [store] => 1234 [total] => 1234 [items] => Array )
Can anyone assist me with finding a way to access the $items array data
Thank you in advance