Replace json_encode by serialize in method _encode

To avoid this error :
PHP Warning: json_encode(): recursion detected