json_encode() supports the 3rd argument from PHP 5.5, check for it