diff options
Diffstat (limited to 'lib/chef/json_compat.rb')
-rw-r--r-- | lib/chef/json_compat.rb | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/chef/json_compat.rb b/lib/chef/json_compat.rb index baab1386f6..2dbb607d9b 100644 --- a/lib/chef/json_compat.rb +++ b/lib/chef/json_compat.rb @@ -18,6 +18,7 @@ # Wrapper class for interacting with JSON. require 'ffi_yajl' +require 'ffi_yajl/json_gem' # XXX: parts of chef require JSON gem's Hash#to_json monkeypatch class Chef class JSONCompat @@ -87,17 +88,14 @@ class Chef end def to_json(obj, opts = nil) - ::FFI_Yajl::Encoder.encode(obj, opts) + obj.to_json(opts) end def to_json_pretty(obj, opts = nil) - opts ||= {} - options_map = {} - options_map[:pretty] = true - options_map[:indent] = opts[:indent] if opts.has_key?(:indent) - ::FFI_Yajl::Encoder.encode(obj, options_map).chomp + ::JSON.pretty_generate(obj, opts) end + # Map +json_class+ to a Class object. We use a +case+ instead of a Hash # assigned to a constant because otherwise this file could not be loaded # until all the constants were defined, which means you'd have to load |