Migrated to MultiJson from JSON gem.
This commit is contained in:
parent
04ec835ca1
commit
0bc3d4936b
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
|
|
||||||
require 'httpadapter'
|
require 'httpadapter'
|
||||||
require 'json'
|
require 'multi_json'
|
||||||
require 'stringio'
|
require 'stringio'
|
||||||
|
|
||||||
require 'google/api_client/version'
|
require 'google/api_client/version'
|
||||||
|
@ -268,7 +268,7 @@ module Google
|
||||||
"Expected String or StringIO, got #{discovery_document.class}."
|
"Expected String or StringIO, got #{discovery_document.class}."
|
||||||
end
|
end
|
||||||
@discovery_documents["#{api}:#{version}"] =
|
@discovery_documents["#{api}:#{version}"] =
|
||||||
::JSON.parse(discovery_document)
|
MultiJson.decode(discovery_document)
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -290,7 +290,7 @@ module Google
|
||||||
accu.write(chunk)
|
accu.write(chunk)
|
||||||
accu
|
accu
|
||||||
end
|
end
|
||||||
::JSON.parse(merged_body.string)
|
MultiJson.decode(merged_body.string)
|
||||||
elsif status >= 400 && status < 500
|
elsif status >= 400 && status < 500
|
||||||
_, request_uri, _, _ = request
|
_, request_uri, _, _ = request
|
||||||
raise ClientError,
|
raise ClientError,
|
||||||
|
@ -330,7 +330,7 @@ module Google
|
||||||
accu.write(chunk)
|
accu.write(chunk)
|
||||||
accu
|
accu
|
||||||
end
|
end
|
||||||
::JSON.parse(merged_body.string)
|
MultiJson.decode(merged_body.string)
|
||||||
elsif status >= 400 && status < 500
|
elsif status >= 400 && status < 500
|
||||||
_, request_uri, _, _ = request
|
_, request_uri, _, _ = request
|
||||||
raise ClientError,
|
raise ClientError,
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
|
|
||||||
require 'time'
|
require 'time'
|
||||||
require 'json'
|
require 'multi_json'
|
||||||
require 'base64'
|
require 'base64'
|
||||||
require 'autoparse'
|
require 'autoparse'
|
||||||
require 'addressable/uri'
|
require 'addressable/uri'
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
|
||||||
require 'json'
|
require 'multi_json'
|
||||||
|
|
||||||
|
|
||||||
module Google
|
module Google
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
|
||||||
require 'json'
|
require 'multi_json'
|
||||||
require 'google/api_client/parser'
|
require 'google/api_client/parser'
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ module Google
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(data)
|
def initialize(data)
|
||||||
@data = data.kind_of?(Hash) ? data : ::JSON.parse(data)
|
@data = data.kind_of?(Hash) ? data : MultiJson.decode(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
def [](key)
|
def [](key)
|
||||||
|
@ -107,7 +107,7 @@ module Google
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.parse(json)
|
def self.parse(json)
|
||||||
data = json.kind_of?(Hash) ? json : ::JSON.parse(json)
|
data = json.kind_of?(Hash) ? json : MultiJson.decode(json)
|
||||||
parser = self.match(data)
|
parser = self.match(data)
|
||||||
if parser
|
if parser
|
||||||
return parser.new(data)
|
return parser.new(data)
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
|
|
||||||
require 'stringio'
|
require 'stringio'
|
||||||
require 'json'
|
require 'multi_json'
|
||||||
require 'addressable/uri'
|
require 'addressable/uri'
|
||||||
require 'google/api_client/discovery'
|
require 'google/api_client/discovery'
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ module Google
|
||||||
if options[:body_object].respond_to?(:to_json)
|
if options[:body_object].respond_to?(:to_json)
|
||||||
serialized_body = options[:body_object].to_json
|
serialized_body = options[:body_object].to_json
|
||||||
elsif options[:body_object].respond_to?(:to_hash)
|
elsif options[:body_object].respond_to?(:to_hash)
|
||||||
serialized_body = JSON.generate(options[:body_object].to_hash)
|
serialized_body = MultiJson.encode(options[:body_object].to_hash)
|
||||||
else
|
else
|
||||||
raise TypeError,
|
raise TypeError,
|
||||||
'Could not convert body object to JSON.' +
|
'Could not convert body object to JSON.' +
|
||||||
|
|
|
@ -57,7 +57,7 @@ module Google
|
||||||
data = self.body
|
data = self.body
|
||||||
case media_type
|
case media_type
|
||||||
when 'application/json'
|
when 'application/json'
|
||||||
data = ::JSON.parse(data)
|
data = MultiJson.decode(data)
|
||||||
# Strip data wrapper, if present
|
# Strip data wrapper, if present
|
||||||
data = data['data'] if data.has_key?('data')
|
data = data['data'] if data.has_key?('data')
|
||||||
else
|
else
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
require 'json'
|
require 'multi_json'
|
||||||
require 'signet/oauth_1/client'
|
require 'signet/oauth_1/client'
|
||||||
require 'httpadapter/adapters/net_http'
|
require 'httpadapter/adapters/net_http'
|
||||||
|
|
||||||
|
@ -298,7 +298,7 @@ describe Google::APIClient do
|
||||||
result = @client.execute(
|
result = @client.execute(
|
||||||
@prediction.training.insert,
|
@prediction.training.insert,
|
||||||
{},
|
{},
|
||||||
JSON.generate({"id" => "bucket/object"}),
|
MultiJson.encode({"id" => "bucket/object"}),
|
||||||
{'Content-Type' => 'application/json'}
|
{'Content-Type' => 'application/json'}
|
||||||
)
|
)
|
||||||
method, uri, headers, body = result.request
|
method, uri, headers, body = result.request
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
require 'json'
|
require 'multi_json'
|
||||||
require 'google/api_client/parsers/json_parser'
|
require 'google/api_client/parsers/json_parser'
|
||||||
require 'google/api_client/parsers/json/error_parser'
|
require 'google/api_client/parsers/json/error_parser'
|
||||||
require 'google/api_client/parsers/json/pagination'
|
require 'google/api_client/parsers/json/pagination'
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace :gem do
|
||||||
s.add_runtime_dependency('addressable', '~> 2.2.2')
|
s.add_runtime_dependency('addressable', '~> 2.2.2')
|
||||||
s.add_runtime_dependency('httpadapter', '~> 1.0.1')
|
s.add_runtime_dependency('httpadapter', '~> 1.0.1')
|
||||||
s.add_runtime_dependency('autoparse', '~> 0.2.0')
|
s.add_runtime_dependency('autoparse', '~> 0.2.0')
|
||||||
s.add_runtime_dependency('json', '>= 1.4.6')
|
s.add_runtime_dependency('multi_json', '>= 1.0.0')
|
||||||
s.add_runtime_dependency('extlib', '>= 0.9.15')
|
s.add_runtime_dependency('extlib', '>= 0.9.15')
|
||||||
|
|
||||||
# Dependencies used in the CLI
|
# Dependencies used in the CLI
|
||||||
|
|
Loading…
Reference in New Issue