diff options
author | danielsdeleo <dan@opscode.com> | 2013-02-11 15:52:18 -0800 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2013-02-11 15:52:18 -0800 |
commit | c7e99e50b1b9bba72b3fd907e1fb3748b901eeee (patch) | |
tree | dfcfde97ae88790cfbcb311d3536465ccb6103cb /lib/chef/json_compat.rb | |
parent | 07bc5331feac1ceaf0627aaf2c52b213f39be45a (diff) | |
download | chef-c7e99e50b1b9bba72b3fd907e1fb3748b901eeee.tar.gz |
rdoc json compat methods
Diffstat (limited to 'lib/chef/json_compat.rb')
-rw-r--r-- | lib/chef/json_compat.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/chef/json_compat.rb b/lib/chef/json_compat.rb index 410dd51816..80afc163e7 100644 --- a/lib/chef/json_compat.rb +++ b/lib/chef/json_compat.rb @@ -52,6 +52,11 @@ class Chef # Just call the JSON gem's parse method with a modified :max_nesting field def from_json(source, opts = {}) obj = ::Yajl::Parser.parse(source) + + # The old default in the json gem (which we are mimicing because we + # sadly rely on this misfeature) is to "create additions" i.e., convert + # JSON objects into ruby objects. Explicit :create_additions => false + # is required to turn it off. if opts[:create_additions].nil? || opts[:create_additions] map_to_rb_obj(obj) else @@ -59,6 +64,8 @@ class Chef end end + # Look at an object that's a basic type (from json parse) and convert it + # to an instance of Chef classes if desired. def map_to_rb_obj(json_obj) res = case json_obj when Hash |