我从REST Flight API中获得了JSON格式的响应,但无法从JSON转换为数组。
我已经尝试过json编码,但是它只显示打印json响应,而没有将其转换为数组
Php控制器:
public function search_flites() {php controller
header('Content-type: application/json');
$this->load->library('curl');
$result = $this->curl->simple_get('http://13.235.39.41:8080/ettafly/api/session');
$Data = json_decode($result);
$session_id = $Data->SessionId;
$url = 'http://13.235.39.41:8080/ettafly/api/flightavaliblity';
$ch = curl_init($url);
$jsonData = array(
"user_id" => "Ettafly_APITest2019","user_password" => "Ettafly_TestPswd2019","access" => "Test","ip_address" => "13.235.39.41","session_id" => "$session_id","journey_type" => "OneWay","airport_from_code" => "DEL","airport_to_code" => "BOM","departure_date" => "2019-11-16","return_date" => "2019-11-18","adult_flight" => "1","child_flight" => "0","infant_flight" => "0","class_type" => "Economy","target" => "Test"
);
$ch = curl_init($url);
$jsonDataEncoded = json_encode($jsonData,JSON_PRETTY_PRINT);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$jsonDataEncoded);
$result2 = curl_setopt($ch,CURLOPT_HTTPHEADER,array('Content-Type: application/json'));
$Data2 = json_decode($result2,true);
}