summaryrefslogtreecommitdiff
path: root/chef/lib
diff options
context:
space:
mode:
Diffstat (limited to 'chef/lib')
-rw-r--r--chef/lib/chef/api_client.rb2
-rw-r--r--chef/lib/chef/application/client.rb2
-rw-r--r--chef/lib/chef/application/solo.rb2
-rw-r--r--chef/lib/chef/cookbook/metadata.rb4
-rw-r--r--chef/lib/chef/couchdb.rb2
-rw-r--r--chef/lib/chef/data_bag.rb2
-rw-r--r--chef/lib/chef/data_bag_item.rb2
-rw-r--r--chef/lib/chef/file_cache.rb2
-rw-r--r--chef/lib/chef/handler/json_file.rb2
-rw-r--r--chef/lib/chef/index_queue/consumer.rb4
-rw-r--r--chef/lib/chef/json.rb52
-rw-r--r--chef/lib/chef/knife.rb12
-rw-r--r--chef/lib/chef/knife/bootstrap.rb2
-rw-r--r--chef/lib/chef/knife/client_bulk_delete.rb2
-rw-r--r--chef/lib/chef/knife/client_create.rb2
-rw-r--r--chef/lib/chef/knife/client_delete.rb2
-rw-r--r--chef/lib/chef/knife/client_edit.rb2
-rw-r--r--chef/lib/chef/knife/client_list.rb2
-rw-r--r--chef/lib/chef/knife/client_reregister.rb2
-rw-r--r--chef/lib/chef/knife/client_show.rb2
-rw-r--r--chef/lib/chef/knife/cookbook_create.rb2
-rw-r--r--chef/lib/chef/knife/cookbook_list.rb2
-rw-r--r--chef/lib/chef/knife/cookbook_metadata.rb2
-rw-r--r--chef/lib/chef/knife/cookbook_show.rb2
-rw-r--r--chef/lib/chef/knife/cookbook_site_share.rb2
-rw-r--r--chef/lib/chef/knife/cookbook_site_unshare.rb2
-rw-r--r--chef/lib/chef/knife/data_bag_from_file.rb1
-rw-r--r--chef/lib/chef/knife/ec2_instance_data.rb2
-rw-r--r--chef/lib/chef/knife/ec2_server_create.rb2
-rw-r--r--chef/lib/chef/knife/ec2_server_delete.rb2
-rw-r--r--chef/lib/chef/knife/ec2_server_list.rb2
-rw-r--r--chef/lib/chef/knife/node_bulk_delete.rb2
-rw-r--r--chef/lib/chef/knife/node_create.rb2
-rw-r--r--chef/lib/chef/knife/node_delete.rb2
-rw-r--r--chef/lib/chef/knife/node_edit.rb2
-rw-r--r--chef/lib/chef/knife/node_from_file.rb2
-rw-r--r--chef/lib/chef/knife/node_list.rb2
-rw-r--r--chef/lib/chef/knife/node_run_list_add.rb2
-rw-r--r--chef/lib/chef/knife/node_run_list_remove.rb2
-rw-r--r--chef/lib/chef/knife/node_show.rb2
-rw-r--r--chef/lib/chef/knife/rackspace_server_create.rb2
-rw-r--r--chef/lib/chef/knife/rackspace_server_delete.rb2
-rw-r--r--chef/lib/chef/knife/rackspace_server_list.rb2
-rw-r--r--chef/lib/chef/knife/role_bulk_delete.rb2
-rw-r--r--chef/lib/chef/knife/role_create.rb2
-rw-r--r--chef/lib/chef/knife/role_delete.rb2
-rw-r--r--chef/lib/chef/knife/role_edit.rb2
-rw-r--r--chef/lib/chef/knife/role_from_file.rb2
-rw-r--r--chef/lib/chef/knife/role_list.rb2
-rw-r--r--chef/lib/chef/knife/role_show.rb2
-rw-r--r--chef/lib/chef/knife/slicehost_images_list.rb2
-rw-r--r--chef/lib/chef/knife/slicehost_server_create.rb2
-rw-r--r--chef/lib/chef/knife/slicehost_server_delete.rb2
-rw-r--r--chef/lib/chef/knife/slicehost_server_list.rb2
-rw-r--r--chef/lib/chef/knife/terremark_server_create.rb2
-rw-r--r--chef/lib/chef/knife/terremark_server_delete.rb2
-rw-r--r--chef/lib/chef/knife/terremark_server_list.rb2
-rw-r--r--chef/lib/chef/node.rb3
-rw-r--r--chef/lib/chef/openid_registration.rb2
-rw-r--r--chef/lib/chef/provider/deploy/revision.rb2
-rw-r--r--chef/lib/chef/rest.rb14
-rw-r--r--chef/lib/chef/role.rb4
-rw-r--r--chef/lib/chef/shef.rb4
-rw-r--r--chef/lib/chef/shef/ext.rb4
-rw-r--r--chef/lib/chef/tasks/chef_repo.rake2
-rw-r--r--chef/lib/chef/webui_user.rb2
66 files changed, 134 insertions, 80 deletions
diff --git a/chef/lib/chef/api_client.rb b/chef/lib/chef/api_client.rb
index 0dd7ee8042..d7eed5a16b 100644
--- a/chef/lib/chef/api_client.rb
+++ b/chef/lib/chef/api_client.rb
@@ -24,7 +24,7 @@ require 'chef/couchdb'
require 'chef/certificate'
require 'chef/index_queue'
require 'extlib'
-require 'json'
+require 'chef/json'
class Chef
class ApiClient
diff --git a/chef/lib/chef/application/client.rb b/chef/lib/chef/application/client.rb
index 4d8addd9af..b8df754ece 100644
--- a/chef/lib/chef/application/client.rb
+++ b/chef/lib/chef/application/client.rb
@@ -181,7 +181,7 @@ class Chef::Application::Client < Chef::Application
end
begin
- @chef_client_json = JSON.parse(json_io.read)
+ @chef_client_json = Chef::JSON.from_json(json_io.read)
json_io.close unless json_io.closed?
rescue JSON::ParserError => error
Chef::Application.fatal!("Could not parse the provided JSON file (#{Chef::Config[:json_attribs]})!: " + error.message, 2)
diff --git a/chef/lib/chef/application/solo.rb b/chef/lib/chef/application/solo.rb
index e1458195b8..35887d0d70 100644
--- a/chef/lib/chef/application/solo.rb
+++ b/chef/lib/chef/application/solo.rb
@@ -145,7 +145,7 @@ class Chef::Application::Solo < Chef::Application
end
begin
- @chef_solo_json = JSON.parse(json_io.read)
+ @chef_solo_json = Chef::JSON.from_json(json_io.read)
json_io.close unless json_io.closed?
rescue JSON::ParserError => error
Chef::Application.fatal!("Could not parse the provided JSON file (#{Chef::Config[:json_attribs]})!: " + error.message, 2)
diff --git a/chef/lib/chef/cookbook/metadata.rb b/chef/lib/chef/cookbook/metadata.rb
index 2f31893ceb..79ef860b89 100644
--- a/chef/lib/chef/cookbook/metadata.rb
+++ b/chef/lib/chef/cookbook/metadata.rb
@@ -430,12 +430,12 @@ class Chef
end
def self.from_json(string)
- o = JSON.parse(string)
+ o = Chef::JSON.from_json(string)
self.from_hash(o)
end
def from_json(string)
- o = JSON.parse(string)
+ o = Chef::JSON.from_json(string)
from_hash(o)
end
diff --git a/chef/lib/chef/couchdb.rb b/chef/lib/chef/couchdb.rb
index 27f4d2dc45..3dfd8ccbd8 100644
--- a/chef/lib/chef/couchdb.rb
+++ b/chef/lib/chef/couchdb.rb
@@ -21,7 +21,7 @@ require 'chef/config'
require 'chef/rest'
require 'chef/log'
require 'digest/sha2'
-require 'json'
+require 'chef/json'
# We want to fail on create if uuidtools isn't installed
begin
diff --git a/chef/lib/chef/data_bag.rb b/chef/lib/chef/data_bag.rb
index 512293e717..f14812cf40 100644
--- a/chef/lib/chef/data_bag.rb
+++ b/chef/lib/chef/data_bag.rb
@@ -25,7 +25,7 @@ require 'chef/couchdb'
require 'chef/data_bag_item'
require 'chef/index_queue'
require 'extlib'
-require 'json'
+require 'chef/json'
class Chef
class DataBag
diff --git a/chef/lib/chef/data_bag_item.rb b/chef/lib/chef/data_bag_item.rb
index d5fba01563..15d046efeb 100644
--- a/chef/lib/chef/data_bag_item.rb
+++ b/chef/lib/chef/data_bag_item.rb
@@ -25,7 +25,7 @@ require 'chef/couchdb'
require 'chef/index_queue'
require 'chef/data_bag'
require 'extlib'
-require 'json'
+require 'chef/json'
class Chef
class DataBagItem
diff --git a/chef/lib/chef/file_cache.rb b/chef/lib/chef/file_cache.rb
index 9208f53d92..f558e67e9e 100644
--- a/chef/lib/chef/file_cache.rb
+++ b/chef/lib/chef/file_cache.rb
@@ -18,7 +18,7 @@
require 'chef/mixin/params_validate'
require 'chef/mixin/create_path'
require 'chef/exceptions'
-require 'json'
+require 'chef/json'
require 'fileutils'
class Chef
diff --git a/chef/lib/chef/handler/json_file.rb b/chef/lib/chef/handler/json_file.rb
index 580ede671b..8bac5232d0 100644
--- a/chef/lib/chef/handler/json_file.rb
+++ b/chef/lib/chef/handler/json_file.rb
@@ -41,7 +41,7 @@ class Chef
build_report_dir
savetime = Time.now.strftime("%Y%m%d%H%M%S")
File.open(File.join(config[:path], "chef-run-report-#{savetime}.json"), "w") do |file|
- file.puts JSON.pretty_generate(data)
+ file.puts Chef::JSON.to_json_pretty(data)
end
end
diff --git a/chef/lib/chef/index_queue/consumer.rb b/chef/lib/chef/index_queue/consumer.rb
index b7be42ed76..18e8d3b8fc 100644
--- a/chef/lib/chef/index_queue/consumer.rb
+++ b/chef/lib/chef/index_queue/consumer.rb
@@ -56,7 +56,7 @@ class Chef
alias :start :run
def call_action_for_message(message)
- amqp_payload = JSON.parse(message[:payload], :create_additions => false, :max_nesting => false)
+ amqp_payload = Chef::JSON.from_json(message[:payload], :create_additions => false, :max_nesting => false)
action = amqp_payload["action"].to_sym
app_payload = amqp_payload["payload"]
assert_method_whitelisted(action)
@@ -73,4 +73,4 @@ class Chef
end
end
-end \ No newline at end of file
+end
diff --git a/chef/lib/chef/json.rb b/chef/lib/chef/json.rb
new file mode 100644
index 0000000000..1b1618c132
--- /dev/null
+++ b/chef/lib/chef/json.rb
@@ -0,0 +1,52 @@
+#
+# Author:: Tim Hinderliter (<tim@opscode.com>)
+# Copyright:: Copyright (c) 2010 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Wrapper class for interacting with JSON.
+
+require 'json'
+
+class Chef
+ class JSON
+ JSON_MAX_NESTING = 1000
+
+ class <<self
+ # See PL-538. Increase the max nesting for JSON, which defaults to 19,
+ # and isn't enough for some deep node (for example) structures.
+ def opts_add_max_nesting(opts)
+ if opts.nil? || !opts.has_key?(:max_nesting)
+ opts = opts.nil? ? Hash.new : opts.clone
+ opts[:max_nesting] = JSON_MAX_NESTING
+ end
+ opts
+ end
+
+ # Just call the JSON gem's parse method with a modified :max_nesting field
+ def from_json(source, opts = {})
+ ::JSON.parse(source, opts_add_max_nesting(opts))
+ end
+
+ def to_json(obj, opts = nil)
+ #::JSON.generate(obj, opts_add_max_nesting(opts))
+ obj.to_json(opts_add_max_nesting(opts))
+ end
+
+ def to_json_pretty(obj, opts = nil)
+ ::JSON.pretty_generate(obj, opts_add_max_nesting(opts))
+ end
+ end
+ end
+end
diff --git a/chef/lib/chef/knife.rb b/chef/lib/chef/knife.rb
index 1351b77326..d284ea622f 100644
--- a/chef/lib/chef/knife.rb
+++ b/chef/lib/chef/knife.rb
@@ -289,7 +289,7 @@ class Chef
def output(data)
case config[:format]
when "json", nil
- stdout.puts JSON.pretty_generate(data)
+ stdout.puts Chef::JSON.to_json_pretty(data)
when "yaml"
require 'yaml'
stdout.puts YAML::dump(data)
@@ -335,7 +335,7 @@ class Chef
end
def edit_data(data, parse_output=true)
- output = JSON.pretty_generate(data)
+ output = Chef::JSON.to_json_pretty(data)
if (!config[:no_editor])
filename = "knife-edit-"
@@ -353,7 +353,7 @@ class Chef
File.unlink(filename)
end
- parse_output ? JSON.parse(output) : output
+ parse_output ? Chef::JSON.from_json(output) : output
end
def confirm(question, append_instructions=true)
@@ -404,7 +404,7 @@ class Chef
case from_file
when /\.(js|json)$/
- JSON.parse(IO.read(filename))
+ Chef::JSON.from_json(IO.read(filename))
when /\.rb$/
r = klass.new
r.from_file(filename)
@@ -434,8 +434,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 = JSON.parse(object.to_json, :create_additions => false)
- output_parsed_again = JSON.parse(output.to_json, :create_additions => false)
+ object_parsed_again = Chef::JSON.from_json(Chef::JSON.to_json(object), :create_additions => false)
+ output_parsed_again = Chef::JSON.from_json(Chef::JSON.to_json(output), :create_additions => false)
if object_parsed_again != output_parsed_again
output.save
self.msg("Saved #{output}")
diff --git a/chef/lib/chef/knife/bootstrap.rb b/chef/lib/chef/knife/bootstrap.rb
index 968c69076f..37a88f26a8 100644
--- a/chef/lib/chef/knife/bootstrap.rb
+++ b/chef/lib/chef/knife/bootstrap.rb
@@ -17,7 +17,7 @@
#
require 'chef/knife'
-require 'json'
+require 'chef/json'
require 'tempfile'
require 'erubis'
diff --git a/chef/lib/chef/knife/client_bulk_delete.rb b/chef/lib/chef/knife/client_bulk_delete.rb
index 9f7e0c8ace..a856c34dc3 100644
--- a/chef/lib/chef/knife/client_bulk_delete.rb
+++ b/chef/lib/chef/knife/client_bulk_delete.rb
@@ -18,7 +18,7 @@
require 'chef/knife'
require 'chef/api_client'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/client_create.rb b/chef/lib/chef/knife/client_create.rb
index d25e77f4e2..963fe7bc60 100644
--- a/chef/lib/chef/knife/client_create.rb
+++ b/chef/lib/chef/knife/client_create.rb
@@ -18,7 +18,7 @@
require 'chef/knife'
require 'chef/api_client'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/client_delete.rb b/chef/lib/chef/knife/client_delete.rb
index 2815369e5c..fa25b4188a 100644
--- a/chef/lib/chef/knife/client_delete.rb
+++ b/chef/lib/chef/knife/client_delete.rb
@@ -18,7 +18,7 @@
require 'chef/knife'
require 'chef/api_client'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/client_edit.rb b/chef/lib/chef/knife/client_edit.rb
index 293e2ae904..cac55956de 100644
--- a/chef/lib/chef/knife/client_edit.rb
+++ b/chef/lib/chef/knife/client_edit.rb
@@ -18,7 +18,7 @@
require 'chef/knife'
require 'chef/api_client'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/client_list.rb b/chef/lib/chef/knife/client_list.rb
index 1a0942ae4a..43ee6e4632 100644
--- a/chef/lib/chef/knife/client_list.rb
+++ b/chef/lib/chef/knife/client_list.rb
@@ -18,7 +18,7 @@
require 'chef/knife'
require 'chef/api_client'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/client_reregister.rb b/chef/lib/chef/knife/client_reregister.rb
index e865b8bf66..257b72da39 100644
--- a/chef/lib/chef/knife/client_reregister.rb
+++ b/chef/lib/chef/knife/client_reregister.rb
@@ -18,7 +18,7 @@
require 'chef/knife'
require 'chef/api_client'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/client_show.rb b/chef/lib/chef/knife/client_show.rb
index 7c84b6cfab..b8078ccf78 100644
--- a/chef/lib/chef/knife/client_show.rb
+++ b/chef/lib/chef/knife/client_show.rb
@@ -18,7 +18,7 @@
require 'chef/knife'
require 'chef/api_client'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/cookbook_create.rb b/chef/lib/chef/knife/cookbook_create.rb
index 3098a27d9b..aed540ba6b 100644
--- a/chef/lib/chef/knife/cookbook_create.rb
+++ b/chef/lib/chef/knife/cookbook_create.rb
@@ -17,7 +17,7 @@
#
require 'chef/knife'
-require 'json'
+require 'chef/json'
require 'uri'
require 'chef/mixin/shell_out'
diff --git a/chef/lib/chef/knife/cookbook_list.rb b/chef/lib/chef/knife/cookbook_list.rb
index 9d201742d4..857431cbbc 100644
--- a/chef/lib/chef/knife/cookbook_list.rb
+++ b/chef/lib/chef/knife/cookbook_list.rb
@@ -17,7 +17,7 @@
#
require 'chef/knife'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/cookbook_metadata.rb b/chef/lib/chef/knife/cookbook_metadata.rb
index 8182e57502..f15f47b7d3 100644
--- a/chef/lib/chef/knife/cookbook_metadata.rb
+++ b/chef/lib/chef/knife/cookbook_metadata.rb
@@ -69,7 +69,7 @@ class Chef
md.from_file(file)
json_file = File.join(File.dirname(file), 'metadata.json')
File.open(json_file, "w") do |f|
- f.write(JSON.pretty_generate(md))
+ f.write(Chef::JSON.to_json_pretty(md))
end
generated = true
Chef::Log.debug("Generated #{json_file}")
diff --git a/chef/lib/chef/knife/cookbook_show.rb b/chef/lib/chef/knife/cookbook_show.rb
index 7537c97cca..2b858e1569 100644
--- a/chef/lib/chef/knife/cookbook_show.rb
+++ b/chef/lib/chef/knife/cookbook_show.rb
@@ -17,7 +17,7 @@
#
require 'chef/knife'
-require 'json'
+require 'chef/json'
require 'uri'
class Chef
diff --git a/chef/lib/chef/knife/cookbook_site_share.rb b/chef/lib/chef/knife/cookbook_site_share.rb
index 3a2f7e5ec3..356902eed2 100644
--- a/chef/lib/chef/knife/cookbook_site_share.rb
+++ b/chef/lib/chef/knife/cookbook_site_share.rb
@@ -85,7 +85,7 @@ class Chef
:cookbook => category_string
})
- res = JSON.parse(http_resp.body)
+ res = Chef::JSON.from_json(http_resp.body)
if http_resp.code.to_i != 201
if res['error_messages']
if res['error_messages'][0] =~ /Version already exists/
diff --git a/chef/lib/chef/knife/cookbook_site_unshare.rb b/chef/lib/chef/knife/cookbook_site_unshare.rb
index e870dbb814..6c3736f7c1 100644
--- a/chef/lib/chef/knife/cookbook_site_unshare.rb
+++ b/chef/lib/chef/knife/cookbook_site_unshare.rb
@@ -18,6 +18,8 @@
#
require 'chef/knife'
+require 'chef/environment'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/data_bag_from_file.rb b/chef/lib/chef/knife/data_bag_from_file.rb
index 2c8417a4f9..6a513e5dc5 100644
--- a/chef/lib/chef/knife/data_bag_from_file.rb
+++ b/chef/lib/chef/knife/data_bag_from_file.rb
@@ -19,6 +19,7 @@
require 'chef/knife'
require 'chef/data_bag'
require 'chef/data_bag_item'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/ec2_instance_data.rb b/chef/lib/chef/knife/ec2_instance_data.rb
index b69a2330c1..43265b5cc2 100644
--- a/chef/lib/chef/knife/ec2_instance_data.rb
+++ b/chef/lib/chef/knife/ec2_instance_data.rb
@@ -17,7 +17,7 @@
#
require 'chef/knife'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/ec2_server_create.rb b/chef/lib/chef/knife/ec2_server_create.rb
index 3311786817..ae9c108acd 100644
--- a/chef/lib/chef/knife/ec2_server_create.rb
+++ b/chef/lib/chef/knife/ec2_server_create.rb
@@ -18,7 +18,7 @@
require 'socket'
require 'chef/knife'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/ec2_server_delete.rb b/chef/lib/chef/knife/ec2_server_delete.rb
index 161c558b37..1f1d45c55c 100644
--- a/chef/lib/chef/knife/ec2_server_delete.rb
+++ b/chef/lib/chef/knife/ec2_server_delete.rb
@@ -17,7 +17,7 @@
#
require 'chef/knife'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/ec2_server_list.rb b/chef/lib/chef/knife/ec2_server_list.rb
index 0711cbcf6a..7dabc4688d 100644
--- a/chef/lib/chef/knife/ec2_server_list.rb
+++ b/chef/lib/chef/knife/ec2_server_list.rb
@@ -17,7 +17,7 @@
#
require 'chef/knife'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/node_bulk_delete.rb b/chef/lib/chef/knife/node_bulk_delete.rb
index 1958c63836..621b8ae0ec 100644
--- a/chef/lib/chef/knife/node_bulk_delete.rb
+++ b/chef/lib/chef/knife/node_bulk_delete.rb
@@ -18,7 +18,7 @@
require 'chef/knife'
require 'chef/node'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/node_create.rb b/chef/lib/chef/knife/node_create.rb
index 4f14d21ab8..004fea7df1 100644
--- a/chef/lib/chef/knife/node_create.rb
+++ b/chef/lib/chef/knife/node_create.rb
@@ -18,7 +18,7 @@
require 'chef/knife'
require 'chef/node'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/node_delete.rb b/chef/lib/chef/knife/node_delete.rb
index 03113b6003..eef13a46c6 100644
--- a/chef/lib/chef/knife/node_delete.rb
+++ b/chef/lib/chef/knife/node_delete.rb
@@ -18,7 +18,7 @@
require 'chef/knife'
require 'chef/node'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/node_edit.rb b/chef/lib/chef/knife/node_edit.rb
index 5460af5ab0..4ca64c6a59 100644
--- a/chef/lib/chef/knife/node_edit.rb
+++ b/chef/lib/chef/knife/node_edit.rb
@@ -18,7 +18,7 @@
require 'chef/knife'
require 'chef/node'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/node_from_file.rb b/chef/lib/chef/knife/node_from_file.rb
index e644ca17a5..0020827d4e 100644
--- a/chef/lib/chef/knife/node_from_file.rb
+++ b/chef/lib/chef/knife/node_from_file.rb
@@ -18,7 +18,7 @@
require 'chef/knife'
require 'chef/node'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/node_list.rb b/chef/lib/chef/knife/node_list.rb
index 6371b655b6..4a916a3096 100644
--- a/chef/lib/chef/knife/node_list.rb
+++ b/chef/lib/chef/knife/node_list.rb
@@ -18,7 +18,7 @@
require 'chef/knife'
require 'chef/node'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/node_run_list_add.rb b/chef/lib/chef/knife/node_run_list_add.rb
index 9e1602a1e2..41bcf93670 100644
--- a/chef/lib/chef/knife/node_run_list_add.rb
+++ b/chef/lib/chef/knife/node_run_list_add.rb
@@ -18,7 +18,7 @@
require 'chef/knife'
require 'chef/node'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/node_run_list_remove.rb b/chef/lib/chef/knife/node_run_list_remove.rb
index 7bdfc9a66b..a40488abf9 100644
--- a/chef/lib/chef/knife/node_run_list_remove.rb
+++ b/chef/lib/chef/knife/node_run_list_remove.rb
@@ -18,7 +18,7 @@
require 'chef/knife'
require 'chef/node'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/node_show.rb b/chef/lib/chef/knife/node_show.rb
index 971354ba66..f9e8393e96 100644
--- a/chef/lib/chef/knife/node_show.rb
+++ b/chef/lib/chef/knife/node_show.rb
@@ -18,7 +18,7 @@
require 'chef/knife'
require 'chef/node'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/rackspace_server_create.rb b/chef/lib/chef/knife/rackspace_server_create.rb
index 64e16b02f9..5c2347b8f0 100644
--- a/chef/lib/chef/knife/rackspace_server_create.rb
+++ b/chef/lib/chef/knife/rackspace_server_create.rb
@@ -17,7 +17,7 @@
#
require 'chef/knife'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/rackspace_server_delete.rb b/chef/lib/chef/knife/rackspace_server_delete.rb
index e6b133f7c6..db9f6b021a 100644
--- a/chef/lib/chef/knife/rackspace_server_delete.rb
+++ b/chef/lib/chef/knife/rackspace_server_delete.rb
@@ -17,7 +17,7 @@
#
require 'chef/knife'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/rackspace_server_list.rb b/chef/lib/chef/knife/rackspace_server_list.rb
index bae3548cc6..ea0a38f3ab 100644
--- a/chef/lib/chef/knife/rackspace_server_list.rb
+++ b/chef/lib/chef/knife/rackspace_server_list.rb
@@ -17,7 +17,7 @@
#
require 'chef/knife'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/role_bulk_delete.rb b/chef/lib/chef/knife/role_bulk_delete.rb
index 1e4b533c36..95268c799c 100644
--- a/chef/lib/chef/knife/role_bulk_delete.rb
+++ b/chef/lib/chef/knife/role_bulk_delete.rb
@@ -18,7 +18,7 @@
require 'chef/knife'
require 'chef/node'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/role_create.rb b/chef/lib/chef/knife/role_create.rb
index e81b883fdb..d222c0e2ac 100644
--- a/chef/lib/chef/knife/role_create.rb
+++ b/chef/lib/chef/knife/role_create.rb
@@ -18,7 +18,7 @@
require 'chef/knife'
require 'chef/role'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/role_delete.rb b/chef/lib/chef/knife/role_delete.rb
index 14e74ba110..989e1eec42 100644
--- a/chef/lib/chef/knife/role_delete.rb
+++ b/chef/lib/chef/knife/role_delete.rb
@@ -18,7 +18,7 @@
require 'chef/knife'
require 'chef/role'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/role_edit.rb b/chef/lib/chef/knife/role_edit.rb
index 78cad69471..48194bde9b 100644
--- a/chef/lib/chef/knife/role_edit.rb
+++ b/chef/lib/chef/knife/role_edit.rb
@@ -18,7 +18,7 @@
require 'chef/knife'
require 'chef/role'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/role_from_file.rb b/chef/lib/chef/knife/role_from_file.rb
index a12589c4df..ffa4aac6e5 100644
--- a/chef/lib/chef/knife/role_from_file.rb
+++ b/chef/lib/chef/knife/role_from_file.rb
@@ -18,7 +18,7 @@
require 'chef/knife'
require 'chef/role'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/role_list.rb b/chef/lib/chef/knife/role_list.rb
index c617d4aa24..a02979fae4 100644
--- a/chef/lib/chef/knife/role_list.rb
+++ b/chef/lib/chef/knife/role_list.rb
@@ -18,7 +18,7 @@
require 'chef/knife'
require 'chef/node'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/role_show.rb b/chef/lib/chef/knife/role_show.rb
index 952260ae27..14e34c8d0d 100644
--- a/chef/lib/chef/knife/role_show.rb
+++ b/chef/lib/chef/knife/role_show.rb
@@ -18,7 +18,7 @@
require 'chef/knife'
require 'chef/node'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/slicehost_images_list.rb b/chef/lib/chef/knife/slicehost_images_list.rb
index 1adf6edf6e..af9ad827d2 100644
--- a/chef/lib/chef/knife/slicehost_images_list.rb
+++ b/chef/lib/chef/knife/slicehost_images_list.rb
@@ -17,7 +17,7 @@
#
require 'chef/knife'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/slicehost_server_create.rb b/chef/lib/chef/knife/slicehost_server_create.rb
index 086fd387bc..19f802449b 100644
--- a/chef/lib/chef/knife/slicehost_server_create.rb
+++ b/chef/lib/chef/knife/slicehost_server_create.rb
@@ -17,7 +17,7 @@
#
require 'chef/knife'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/slicehost_server_delete.rb b/chef/lib/chef/knife/slicehost_server_delete.rb
index 2d065ea4af..e163a3ae61 100644
--- a/chef/lib/chef/knife/slicehost_server_delete.rb
+++ b/chef/lib/chef/knife/slicehost_server_delete.rb
@@ -17,7 +17,7 @@
#
require 'chef/knife'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/slicehost_server_list.rb b/chef/lib/chef/knife/slicehost_server_list.rb
index 17920094c3..64a16b11b1 100644
--- a/chef/lib/chef/knife/slicehost_server_list.rb
+++ b/chef/lib/chef/knife/slicehost_server_list.rb
@@ -17,7 +17,7 @@
#
require 'chef/knife'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/terremark_server_create.rb b/chef/lib/chef/knife/terremark_server_create.rb
index c32fd9315d..03136ab8c7 100644
--- a/chef/lib/chef/knife/terremark_server_create.rb
+++ b/chef/lib/chef/knife/terremark_server_create.rb
@@ -17,7 +17,7 @@
#
require 'chef/knife'
-require 'json'
+require 'chef/json'
require 'tempfile'
class Chef
diff --git a/chef/lib/chef/knife/terremark_server_delete.rb b/chef/lib/chef/knife/terremark_server_delete.rb
index aeb195c70d..8b3475c6fc 100644
--- a/chef/lib/chef/knife/terremark_server_delete.rb
+++ b/chef/lib/chef/knife/terremark_server_delete.rb
@@ -17,7 +17,7 @@
#
require 'chef/knife'
-require 'json'
+require 'chef/json'
class Chef
class Knife
diff --git a/chef/lib/chef/knife/terremark_server_list.rb b/chef/lib/chef/knife/terremark_server_list.rb
index 20dadbedff..3e90d4cfca 100644
--- a/chef/lib/chef/knife/terremark_server_list.rb
+++ b/chef/lib/chef/knife/terremark_server_list.rb
@@ -17,7 +17,7 @@
#
require 'chef/knife'
-require 'json'
+require 'chef/json'
require 'tempfile'
class Chef
diff --git a/chef/lib/chef/node.rb b/chef/lib/chef/node.rb
index a0aed92258..6bb131a75f 100644
--- a/chef/lib/chef/node.rb
+++ b/chef/lib/chef/node.rb
@@ -32,7 +32,7 @@ require 'chef/run_list'
require 'chef/node/attribute'
require 'chef/index_queue'
require 'extlib'
-require 'json'
+require 'chef/json'
class Chef
class Node
@@ -596,6 +596,5 @@ class Chef
self.from_file(attribute_filename)
self
end
-
end
end
diff --git a/chef/lib/chef/openid_registration.rb b/chef/lib/chef/openid_registration.rb
index 82bee0798e..a97b34d1bc 100644
--- a/chef/lib/chef/openid_registration.rb
+++ b/chef/lib/chef/openid_registration.rb
@@ -21,7 +21,7 @@ require 'chef/mixin/params_validate'
require 'chef/couchdb'
require 'chef/index_queue'
require 'digest/sha1'
-require 'json'
+require 'chef/json'
class Chef
class OpenIDRegistration
diff --git a/chef/lib/chef/provider/deploy/revision.rb b/chef/lib/chef/provider/deploy/revision.rb
index 00a30515ba..18c2c03f8a 100644
--- a/chef/lib/chef/provider/deploy/revision.rb
+++ b/chef/lib/chef/provider/deploy/revision.rb
@@ -56,7 +56,7 @@ class Chef
def load_cache
begin
- JSON.parse(Chef::FileCache.load("revision-deploys/#{new_resource.name}"))
+ Chef::JSON.from_json(Chef::FileCache.load("revision-deploys/#{new_resource.name}"))
rescue Chef::Exceptions::FileNotFound
sorted_releases_from_filesystem
end
diff --git a/chef/lib/chef/rest.rb b/chef/lib/chef/rest.rb
index b721a1bd27..052fa2a513 100644
--- a/chef/lib/chef/rest.rb
+++ b/chef/lib/chef/rest.rb
@@ -22,7 +22,7 @@
require 'net/https'
require 'uri'
-require 'json'
+require 'chef/json'
require 'tempfile'
require 'chef/api_client'
require 'chef/rest/auth_credentials'
@@ -162,7 +162,7 @@ class Chef
#
# Will return the body of the response on success.
def run_request(method, url, headers={}, data=false, limit=nil, raw=false)
- json_body = data ? data.to_json : nil
+ json_body = data ? Chef::JSON.to_json(data) : nil
headers = build_headers(method, url, headers, json_body, raw)
tf = nil
@@ -180,7 +180,7 @@ class Chef
if res.kind_of?(Net::HTTPSuccess)
if res['content-type'] =~ /json/
response_body = res.body.chomp
- JSON.parse(response_body)
+ Chef::JSON.from_json(response_body)
else
if method == :HEAD
true
@@ -196,7 +196,7 @@ class Chef
false
else
if res['content-type'] =~ /json/
- exception = JSON.parse(res.body)
+ exception = Chef::JSON.from_json(res.body)
msg = "HTTP Request Returned #{res.code} #{res.message}: "
msg << (exception["error"].respond_to?(:join) ? exception["error"].join(", ") : exception["error"].to_s)
Chef::Log.warn(msg)
@@ -208,7 +208,7 @@ class Chef
# Runs an HTTP request to a JSON API. File Download not supported.
def api_request(method, url, headers={}, data=false)
- json_body = data ? data.to_json : nil
+ json_body = data ? Chef::JSON.to_json(data) : nil
headers = build_headers(method, url, headers, json_body)
retriable_rest_request(method, url, json_body, headers) do |rest_request|
@@ -216,7 +216,7 @@ class Chef
if response.kind_of?(Net::HTTPSuccess)
if response['content-type'] =~ /json/
- JSON.parse(response.body.chomp)
+ Chef::JSON.from_json(response.body.chomp)
else
Chef::Log.warn("Expected JSON response, but got content-type '#{response['content-type']}'")
response.body
@@ -225,7 +225,7 @@ class Chef
follow_redirect {api_request(:GET, create_url(redirect_location))}
else
if response['content-type'] =~ /json/
- exception = JSON.parse(response.body)
+ exception = Chef::JSON.from_json(response.body)
msg = "HTTP Request Returned #{response.code} #{response.message}: "
msg << (exception["error"].respond_to?(:join) ? exception["error"].join(", ") : exception["error"].to_s)
Chef::Log.warn(msg)
diff --git a/chef/lib/chef/role.rb b/chef/lib/chef/role.rb
index bf0aa32b7a..802ad28752 100644
--- a/chef/lib/chef/role.rb
+++ b/chef/lib/chef/role.rb
@@ -25,7 +25,7 @@ require 'chef/couchdb'
require 'chef/run_list'
require 'chef/index_queue'
require 'extlib'
-require 'json'
+require 'chef/json'
class Chef
class Role
@@ -255,7 +255,7 @@ class Chef
rb_file = File.join(Chef::Config[:role_path], "#{name}.rb")
if File.exists?(js_file) || force == "json"
- JSON.parse(IO.read(js_file))
+ Chef::JSON.from_json(IO.read(js_file))
elsif File.exists?(rb_file) || force == "ruby"
role = Chef::Role.new
role.name(name)
diff --git a/chef/lib/chef/shef.rb b/chef/lib/chef/shef.rb
index e8a224f1e2..bcab49fb4b 100644
--- a/chef/lib/chef/shef.rb
+++ b/chef/lib/chef/shef.rb
@@ -163,7 +163,7 @@ module Shef
end
begin
- @json_attribs = JSON.parse(json_io.read)
+ @json_attribs = Chef::JSON.from_json(json_io.read)
rescue JSON::ParserError => error
fatal!("Could not parse the provided JSON file (#{Chef::Config[:json_attribs]})!: " + error.message, 2)
end
@@ -322,4 +322,4 @@ FOOTER
end
-end \ No newline at end of file
+end
diff --git a/chef/lib/chef/shef/ext.rb b/chef/lib/chef/shef/ext.rb
index a601e86786..77c63cfc07 100644
--- a/chef/lib/chef/shef/ext.rb
+++ b/chef/lib/chef/shef/ext.rb
@@ -327,13 +327,13 @@ E
edited_data = Tempfile.open([filename, ".js"]) do |tempfile|
tempfile.sync = true
- tempfile.puts object.to_json
+ tempfile.puts Chef::JSON.to_json(object)
system("#{Shef.editor.to_s} #{tempfile.path}")
tempfile.rewind
tempfile.read
end
- JSON.parse(edited_data)
+ Chef::JSON.from_json(edited_data)
end
desc "Find and edit API clients"
diff --git a/chef/lib/chef/tasks/chef_repo.rake b/chef/lib/chef/tasks/chef_repo.rake
index cae90c7e67..271a57ee6a 100644
--- a/chef/lib/chef/tasks/chef_repo.rake
+++ b/chef/lib/chef/tasks/chef_repo.rake
@@ -17,7 +17,7 @@
#
require 'rubygems'
-require 'json'
+require 'chef/json'
require 'chef'
require 'chef/role'
require 'chef/cookbook/metadata'
diff --git a/chef/lib/chef/webui_user.rb b/chef/lib/chef/webui_user.rb
index c582722fe8..46932d0f69 100644
--- a/chef/lib/chef/webui_user.rb
+++ b/chef/lib/chef/webui_user.rb
@@ -22,7 +22,7 @@ require 'chef/mixin/params_validate'
require 'chef/couchdb'
require 'chef/index_queue'
require 'digest/sha1'
-require 'json'
+require 'chef/json'
class Chef