diff options
author | tyler-ball <tyleraball@gmail.com> | 2014-09-26 16:18:48 -0700 |
---|---|---|
committer | tyler-ball <tyleraball@gmail.com> | 2014-09-26 16:18:48 -0700 |
commit | e3f2e8471cd97340c28b7541ffb0fa7143a33ca4 (patch) | |
tree | 0b6451871dc704ab7988c19ed5f53e5318a7bd5f /lib/chef_zero/endpoints/rest_object_endpoint.rb | |
parent | 15f4a3e533eefa59412e81c0252af3166541ede0 (diff) | |
download | chef-zero-tball/chef-zero-yajl-replace-json.tar.gz |
Removing 'json' gem dependency, replacing with 'ffi-yajl'tball/chef-zero-yajl-replace-json
Diffstat (limited to 'lib/chef_zero/endpoints/rest_object_endpoint.rb')
-rw-r--r-- | lib/chef_zero/endpoints/rest_object_endpoint.rb | 10 |
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 |