summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlamont-granquist <lamont@scriptkiddie.org>2014-08-12 13:40:48 -0700
committerlamont-granquist <lamont@scriptkiddie.org>2014-08-12 13:40:48 -0700
commita5583fce14173021f6c9e3e145d59ec584c371f8 (patch)
tree87df8b15504f1d3bb7ba3fca7c6eec19ce19a7ab
parent1ad7c5938a3eb83200616142d0a0b857d416a300 (diff)
parentf398a43e00cd08033977ab8437416359cd5a7ea5 (diff)
downloadchef-a5583fce14173021f6c9e3e145d59ec584c371f8.tar.gz
Merge pull request #1806 from opscode/lcg/removing-json-class1
remove some uses of from_json
-rw-r--r--lib/chef/cookbook/cookbook_version_loader.rb4
-rw-r--r--lib/chef/http/json_output.rb2
-rw-r--r--lib/chef/knife/core/node_editor.rb5
-rw-r--r--lib/chef/knife/core/ui.rb4
-rw-r--r--lib/chef/provider/deploy/revision.rb2
-rw-r--r--lib/chef/provider/remote_file/cache_control_data.rb2
6 files changed, 9 insertions, 10 deletions
diff --git a/lib/chef/cookbook/cookbook_version_loader.rb b/lib/chef/cookbook/cookbook_version_loader.rb
index ddbcb785dc..47258c4d4e 100644
--- a/lib/chef/cookbook/cookbook_version_loader.rb
+++ b/lib/chef/cookbook/cookbook_version_loader.rb
@@ -261,7 +261,7 @@ class Chef
def apply_json_cookbook_version_metadata(file)
begin
- data = Chef::JSONCompat.from_json(IO.read(file), :create_additions => false)
+ data = Chef::JSONCompat.parse(IO.read(file))
@metadata.from_hash(data['metadata'])
# the JSON cookbok metadata file is only used by chef-zero.
# The Chef Server API currently does not enforce that the metadata
@@ -281,7 +281,7 @@ class Chef
def set_frozen
if uploaded_cookbook_version_file
begin
- data = Chef::JSONCompat.from_json(IO.read(uploaded_cookbook_version_file), :create_additions => false)
+ data = Chef::JSONCompat.parse(IO.read(uploaded_cookbook_version_file))
@frozen = data['frozen?']
rescue Chef::Exceptions::JSON::ParseError
Chef::Log.error("Couldn't parse cookbook metadata JSON for #@inferred_cookbook_name in #{uploaded_cookbook_version_file}")
diff --git a/lib/chef/http/json_output.rb b/lib/chef/http/json_output.rb
index ae164c6aed..7a3b9c8638 100644
--- a/lib/chef/http/json_output.rb
+++ b/lib/chef/http/json_output.rb
@@ -50,7 +50,7 @@ class Chef
if @inflate_json_class
return_value = Chef::JSONCompat.from_json(http_response.body.chomp)
else
- return_value = Chef::JSONCompat.from_json(http_response.body.chomp, :create_additions => false)
+ return_value = Chef::JSONCompat.parse(http_response.body.chomp)
end
end
[http_response, rest_request, return_value]
diff --git a/lib/chef/knife/core/node_editor.rb b/lib/chef/knife/core/node_editor.rb
index 073492197c..fe14e18d9d 100644
--- a/lib/chef/knife/core/node_editor.rb
+++ b/lib/chef/knife/core/node_editor.rb
@@ -42,8 +42,8 @@ class Chef
end
def updated?
- pristine_copy = Chef::JSONCompat.from_json(Chef::JSONCompat.to_json(node), :create_additions => false)
- updated_copy = Chef::JSONCompat.from_json(Chef::JSONCompat.to_json(@updated_node), :create_additions => false)
+ pristine_copy = Chef::JSONCompat.parse(Chef::JSONCompat.to_json(node))
+ updated_copy = Chef::JSONCompat.parse(Chef::JSONCompat.to_json(@updated_node))
unless pristine_copy == updated_copy
updated_properties = %w{name normal chef_environment run_list default override automatic}.reject do |key|
pristine_copy[key] == updated_copy[key]
@@ -107,4 +107,3 @@ class Chef
end
end
end
-
diff --git a/lib/chef/knife/core/ui.rb b/lib/chef/knife/core/ui.rb
index c4d7d73b00..0007480ea2 100644
--- a/lib/chef/knife/core/ui.rb
+++ b/lib/chef/knife/core/ui.rb
@@ -195,8 +195,8 @@ class Chef
# We wouldn't have to do these shenanigans if all the editable objects
# implemented to_hash, or if to_json against a hash returned a string
# with stable key order.
- object_parsed_again = Chef::JSONCompat.from_json(Chef::JSONCompat.to_json(object), :create_additions => false)
- output_parsed_again = Chef::JSONCompat.from_json(Chef::JSONCompat.to_json(output), :create_additions => false)
+ object_parsed_again = Chef::JSONCompat.parse(Chef::JSONCompat.to_json(object))
+ output_parsed_again = Chef::JSONCompat.parse(Chef::JSONCompat.to_json(output))
if object_parsed_again != output_parsed_again
output.save
self.msg("Saved #{output}")
diff --git a/lib/chef/provider/deploy/revision.rb b/lib/chef/provider/deploy/revision.rb
index 89710088d1..ed65742154 100644
--- a/lib/chef/provider/deploy/revision.rb
+++ b/lib/chef/provider/deploy/revision.rb
@@ -90,7 +90,7 @@ class Chef
def load_cache
begin
- Chef::JSONCompat.from_json(Chef::FileCache.load("revision-deploys/#{new_resource.name}"))
+ Chef::JSONCompat.parse(Chef::FileCache.load("revision-deploys/#{new_resource.name}"))
rescue Chef::Exceptions::FileNotFound
sorted_releases_from_filesystem
end
diff --git a/lib/chef/provider/remote_file/cache_control_data.rb b/lib/chef/provider/remote_file/cache_control_data.rb
index 75b2a5535a..f9b729362c 100644
--- a/lib/chef/provider/remote_file/cache_control_data.rb
+++ b/lib/chef/provider/remote_file/cache_control_data.rb
@@ -139,7 +139,7 @@ class Chef
end
def load_data
- Chef::JSONCompat.from_json(load_json_data)
+ Chef::JSONCompat.parse(load_json_data)
rescue Chef::Exceptions::FileNotFound, Chef::Exceptions::JSON::ParseError
false
end