# File lib/chef/json_compat.rb, line 56 def from_json(source, opts = {}) obj = ::Yajl::Parser.parse(source) unless obj.kind_of?(Hash) || obj.kind_of?(Array) raise JSON::ParserError, "Top level JSON object must be a Hash or Array (actual: #{obj.class})" end # 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 obj end rescue Yajl::ParseError => e raise JSON::ParserError, e.message end