diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ffi_yajl/ffi/encoder.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/ffi_yajl/ffi/encoder.rb b/lib/ffi_yajl/ffi/encoder.rb index 3df366c..a493158 100644 --- a/lib/ffi_yajl/ffi/encoder.rb +++ b/lib/ffi_yajl/ffi/encoder.rb @@ -201,7 +201,11 @@ end # I feel dirty class Object def ffi_yajl(yajl_gen, state) - json = self.to_json(state[:json_opts]) + if self.respond_to?(:to_json) + json = self.to_json(state[:json_opts]) + else + json = self.to_s + end if ( status = FFI_Yajl.yajl_gen_number(yajl_gen, json, json.bytesize) ) != 0 FFI_Yajl::Encoder.raise_error_for_status(status) end |