Added compatibility to use json_encode() in PHP 5.1