diff options
Diffstat (limited to 'lib/chef/json_compat.rb')
-rw-r--r-- | lib/chef/json_compat.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/chef/json_compat.rb b/lib/chef/json_compat.rb index 2dbb607d9b..baab1386f6 100644 --- a/lib/chef/json_compat.rb +++ b/lib/chef/json_compat.rb @@ -18,7 +18,6 @@ # 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 @@ -88,14 +87,17 @@ class Chef end def to_json(obj, opts = nil) - obj.to_json(opts) + ::FFI_Yajl::Encoder.encode(obj, opts) end def to_json_pretty(obj, opts = nil) - ::JSON.pretty_generate(obj, opts) + 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 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 |