summaryrefslogtreecommitdiff
path: root/lib/chef/json_compat.rb
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-08-09 10:04:58 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2014-08-09 10:04:58 -0700
commitadbb0fa85cc45b93ba91dc3019094b312cafb35c (patch)
tree3641e4a23139497a2bd6c3f29af00acad1427beb /lib/chef/json_compat.rb
parent54db1bedbc0a8d00e3b1fc12c50658f1d48b7a6e (diff)
downloadchef-adbb0fa85cc45b93ba91dc3019094b312cafb35c.tar.gz
remove #to_json Monkeypatching
Diffstat (limited to 'lib/chef/json_compat.rb')
-rw-r--r--lib/chef/json_compat.rb10
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