summaryrefslogtreecommitdiff
path: root/lib/chef/json_compat.rb
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-08-09 10:05:47 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2014-08-09 10:05:47 -0700
commitb7a5d28ac34d4661bb8a4e2e92d25e023f60f987 (patch)
tree99fede241b3b91687a15e55a9d045885562c8056 /lib/chef/json_compat.rb
parentadbb0fa85cc45b93ba91dc3019094b312cafb35c (diff)
downloadchef-b7a5d28ac34d4661bb8a4e2e92d25e023f60f987.tar.gz
Revert "remove #to_json Monkeytpatching"
This reverts commit adbb0fa85cc45b93ba91dc3019094b312cafb35c.
Diffstat (limited to 'lib/chef/json_compat.rb')
-rw-r--r--lib/chef/json_compat.rb10
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