summaryrefslogtreecommitdiff
path: root/lib/chef_zero/endpoints/rest_object_endpoint.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef_zero/endpoints/rest_object_endpoint.rb')
-rw-r--r--lib/chef_zero/endpoints/rest_object_endpoint.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/chef_zero/endpoints/rest_object_endpoint.rb b/lib/chef_zero/endpoints/rest_object_endpoint.rb
index 4fb42e3..9e978b4 100644
--- a/lib/chef_zero/endpoints/rest_object_endpoint.rb
+++ b/lib/chef_zero/endpoints/rest_object_endpoint.rb
@@ -1,4 +1,4 @@
-require 'json'
+require 'ffi_yajl'
require 'chef_zero/rest_base'
require 'chef_zero/rest_error_response'
@@ -21,7 +21,7 @@ module ChefZero
def put(request)
# We grab the old body to trigger a 404 if it doesn't exist
old_body = get_data(request)
- request_json = JSON.parse(request.body, :create_additions => false)
+ request_json = FFI_Yajl::Parser.parse(request.body, :create_additions => false)
key = identity_keys.map { |k| request_json[k] }.select { |v| v }.first
key ||= request.rest_path[-1]
# If it's a rename, check for conflict and delete the old value
@@ -49,11 +49,11 @@ module ChefZero
def patch_request_body(request)
existing_value = get_data(request, nil, :nil)
if existing_value
- request_json = JSON.parse(request.body, :create_additions => false)
- existing_json = JSON.parse(existing_value, :create_additions => false)
+ request_json = FFI_Yajl::Parser.parse(request.body, :create_additions => false)
+ existing_json = FFI_Yajl::Parser.parse(existing_value, :create_additions => false)
merged_json = existing_json.merge(request_json)
if merged_json.size > request_json.size
- return JSON.pretty_generate(merged_json)
+ return FFI_Yajl::Encoder.encode(merged_json, :pretty => true)
end
end
request.body