0

I'm trying to put json data into the codeigniter-restserver response, but the json code is put into double quotes effectively rendering it unreadable. I'm trying to set the response like this currently:

$this->response(array(
    'status' => $result['success'],
    'error' => $result['cause'],
    'result' => $result['result']
), $result['statuscode']);

Where $result['result'] is the json code.

Jojo595
  • 65
  • 1
  • 6
  • [This is the CI documentation](https://www.codeigniter.com/userguide3/libraries/output.html#CI_Output::set_content_type). And [here's a gist](https://gist.github.com/olivierobert/4130171) of how to use it. – ourmandave Dec 09 '16 at 23:51

1 Answers1

1

Use the json_decode() to convert your json data in to array. Try it...

$this->response(array(
'status' => $result['success'],
'error' => $result['cause'],
'result' => json_decode($result['result'],true)
), $result['statuscode']);
Hikmat Sijapati
  • 6,869
  • 1
  • 9
  • 19