diff options
author | tyler-ball <tyleraball@gmail.com> | 2014-10-06 09:33:07 -0700 |
---|---|---|
committer | tyler-ball <tyleraball@gmail.com> | 2014-10-06 09:33:07 -0700 |
commit | 1a626e1958a7578455e53fe2f7cc89030b3a4092 (patch) | |
tree | 3eb9a5e9a43a137291c9cf1e85304a2e0a6be0d2 /lib | |
parent | c5d0f4c89fa5a493fd9638d232f70088b4d0556e (diff) | |
download | ffi-yajl-1a626e1958a7578455e53fe2f7cc89030b3a4092.tar.gz |
If an object does not have .to_json, we no longer try to call it
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 |