Module: CartoDB::Client::Utils

Included in:
Connection::CartoDBConnection
Defined in:
lib/cartodb-rb-client/cartodb/client/utils.rb

Class Method Summary collapse

Class Method Details

.parse_json(response) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/cartodb-rb-client/cartodb/client/utils.rb', line 5

def self.parse_json(response)
  json = nil

  unless response.nil? || response.body.nil? || response.body.strip == ''
    begin
      json = ::JSON.parse(response.body, :object_class => CartoDB::Types::Metadata, :symbolize_names => true)
    rescue JSON::ParserError => e
      json = CartoDB::Types::Metadata.new
    end
  end
  json
end