Fix json error handling for PHP <5.3.3 (spotted by @colinmollenhour)