So I have this json :
[{"id":"1","url":"https:\/\/someurl.com\/","starttime":"2010-11-30 16:14:12","finishtime":"2011-09-11 11:32:31","aborted":"0"},{"id":"2","starturl":"http:\/\/someurl.com\/","starttime":"2010-11-30 16:14:12","finishtime":"2013-10-15 14:49:16","aborted":"0"},{"id":"5","starturl":"https:\/\/someurl.com\/","starttime":"2010-11-30 16:14:12","finishtime":"2013-10-17 04:15:58","aborted":"0"}]
Which could be properly processed through : Online Json Viewer
Problem is that when I am trying to decode this string using json_decode
function like:
$decodedJson = json_decode($jsonString);
var_dump($decodedJson);
The result I get is NULL
Can anyone point me out what am I missing?
Edit (fullScript)
try {
$ch = curl_init();
$username ='u';
$password='p';
if (FALSE === $ch)
throw new Exception('failed to initialize');
curl_setopt($ch, CURLOPT_URL,"https://someinternallink");
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($ch, CURLOPT_PROXY, 'someinternalproxy');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, TRUE);
curl_setopt($ch, CURLOPT_CAPATH , 'pathtorootca');
curl_setopt($ch, CURLOPT_ENCODING, 'compress, gzip');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS,'[1]');
$content = curl_exec($ch);
if (FALSE === $content)
throw new Exception(curl_error($ch), curl_errno($ch));
$rawResponse = htmlentities($content);
//$rawResponse variable is 100% identical like I have posted above
try{
print_r(json_decode(trim($rawResponse)));
}
catch (Exception $e){
echo $e;
}
} catch(Exception $e) {
trigger_error(sprintf(
'Curl failed with error #%d: %s',
$e->getCode(), $e->getMessage()),E_USER_ERROR);
}