diff options
author | Tim Smith <tsmith@chef.io> | 2020-11-10 11:32:03 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-10 11:32:03 -0800 |
commit | 5a63faa6988cb91260abe3ffd4c4ff56e5fa5431 (patch) | |
tree | 23e8d56f75a63c973bb09de15be3f6b3107668bd | |
parent | 934ea434db9b1d75379b25437bbc117c5fbec178 (diff) | |
parent | 38b2e9f9f67ff6e5fcfbf50beb9dd969cb594eb3 (diff) | |
download | chef-5a63faa6988cb91260abe3ffd4c4ff56e5fa5431.tar.gz |
Merge pull request #10612 from chef/cleanup-jsoncompat
Cleanup Chef::JSONCompat
-rw-r--r-- | lib/chef/json_compat.rb | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/lib/chef/json_compat.rb b/lib/chef/json_compat.rb index 47d66dba96..b5c9072f6f 100644 --- a/lib/chef/json_compat.rb +++ b/lib/chef/json_compat.rb @@ -24,18 +24,15 @@ require "json" unless defined?(JSON) class Chef class JSONCompat - JSON_MAX_NESTING = 1000 class <<self - # API to use to avoid create_additions def parse(source, opts = {}) FFI_Yajl::Parser.parse(source, opts) rescue FFI_Yajl::ParseError => e raise Chef::Exceptions::JSON::ParseError, e.message end - # Just call the JSON gem's parse method with a modified :max_nesting field def from_json(source, opts = {}) obj = parse(source, opts) @@ -56,10 +53,8 @@ class Chef end def to_json_pretty(obj, opts = nil) - opts ||= {} - options_map = {} - options_map[:pretty] = true - options_map[:indent] = opts[:indent] if opts.key?(:indent) + options_map = { pretty: true } + options_map[:indent] = opts[:indent] if opts.respond_to?(:key?) && opts.key?(:indent) to_json(obj, options_map).chomp end |