Fix json error handling for PHP <5.3.3