I have the following code that returns a bunch of results back from an API, everything inside "" works but the Boolean values that dont have "" dont return, is there something im missing from code for this??
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "URL",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: KEY"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
$json_a2 = json_decode($response, true);
What is been returned back from the API is
"VehicleRegistration": {
"DateOfLastUpdate": "2014-12-19T00:00:00",
"Colour": "BLACK",
"AbiBrokerNetCode": null,
"EngineCapacity": "1598",
"TransmissionCode": "M",
"DtpMakeCode": "DF",
"Exported": false,
"YearOfManufacture": "2014",
"WheelPlan": null,
"DateExported": null,
"Scrapped": false,
}
The false is not showing when i return the results.
falsemakes this invalid JSON. Can you post EXACTLY what you're getting back from the API?falseandtruewithout quotes is perfectly valid.echoboolean values, which of course cast as string as'1'and''(empty string) because that's how PHP is.var_dump($json_a2)to see everything that's returned.