Added json_encode implementation for php<5.2