You can use Codeigniter curl library to parse data in JSON format. For this you can use POST request.
Add this to your JSON file
$this->load->library('Curl');
$url = 'http://your-domin.com/';
$formatJsondata = array(
'username' => 'authenticate-username',
'password' => 'password-authentication'
);
$encodedJsonData = json_encode($formatJsondata);
$this->curl->create($url);
$this->curl->option(CURLOPT_HTTPHEADER, array('Content-type: application/json; Charset=UTF-8'));
$this->curl->post($encodedJsonData);
echo $result = $this->curl->execute();
To show data, add this to config.php file
Class MY_Loader extends CI_Loader {
public $_json_array = array();
public function __construct() {
parent::__construct();
$this->ci = &get_instance();
}
public function view($view, $vars = array(), $return = FALSE) {
$format = $this->ci->input->get('format');
if($format == 'json') {
$this->ci->_json_array[$view] = $vars;
$this->ci->output
->set_output(json_encode($this->ci->_json_array, JSON_NUMERIC_CHECK));
}
else {
parent::view($view, $vars, $return);
}
}
}