westlakedesign/auth_net_receiver · raw_transaction.rb
ruby logo
def json_data
      begin
        return JSON.parse(self.data)
      rescue JSON::ParserError, TypeError => e
        logger.warn "Error while parsing raw transaction data: #{e.message}"
        return {}
      end
    end
Similar code snippets
1.
soracom/soracom-sdk-ruby · api_client.rb
Match rating: 55.33% · See similar code snippets
ruby logo
def parse(response)
      begin
        return JSON.parse(response)
      rescue JSON::ParserError => e
        return {result: response}
      end
    end
2.
Katello/katello_api · base.rb
Match rating: 54.13% · See similar code snippets
ruby logo
def process_data(response)
      data = begin
               JSON.parse(response.body)
             rescue JSON::ParserError
               response.body
             end
      return data, response
    end
3.
mcanevet/freebox_api · freebox.rb
Match rating: 53.01% · See similar code snippets
ruby logo
def process_data(response)
      data = begin
        JSON.parse(response.body)
      rescue JSON::ParserError
        response.body
      end
      logger.debug "Returned data: #{data.inspect}"
      return data
    end
4.
wjdhamilton/easy-json-matcher · json_coercer.rb
Match rating: 51.37% · See similar code snippets
ruby logo
def coerce(json:)
      begin
        JSON.parse(json)
      rescue JSON::ParserError, TypeError
        raise CoercionError.new invalid_string: json
      end
    end
5.
instructure/ims-lti · lti_model.rb
Match rating: 50.89% · See similar code snippets
ruby logo
def from_json(json)
      json = json.to_json unless json.is_a?(String)
      begin
        data = JSON.parse(json)
      rescue
        data = JSON.parse(URI.unescape(json))
      end

      if data.is_a? Array
        data.map { |hash| self.class.from_json(hash.to_json) }
      else
        process_json_hash(data)
      end
    end
6.
ScreenStaring/recharge-api · http_request.rb
Match rating: 50.63% · See similar code snippets
ruby logo
def parse_json(s)
      JSON.parse(s)
    rescue JSON::ParserError => e
      raise Error, "failed to parse JSON response: #{e}"
    end
7.
godfat/rest-core · client_oauth1.rb
Match rating: 50.52% · See similar code snippets
ruby logo
def data_json= json
      self.data = check_sig_and_return_data(Json.decode(json))
    rescue Json.const_get(:ParseError)
      self.data = nil
    end
8.
Shopify/active_fulfillment · shopify_api.rb
Match rating: 49.75% · See similar code snippets
ruby logo
def parse_json(json_data, root)
      response_data = ActiveSupport::JSON.decode(json_data)
      return {} unless response_data.is_a?(Hash)
      response_data[root.underscore] || response_data
    rescue ActiveSupport::JSON.parse_error
      {}
    end
9.
dannyxu2015/imwukong · base.rb
Match rating: 49.6% · See similar code snippets
ruby logo
def safe_json_parse(data)
      JSON.parse(data)
        # rescue TypeError which will cause 'no implicit conversion of HTTParty::Response into String'
    rescue JSON::ParserError, TypeError
      warn data.inspect
      {}
    end
10.
estiens/nanoleaf_ruby · base_requester.rb
Match rating: 48.47% · See similar code snippets
ruby logo
def parse_json(json_string)
      body = {}
      begin
        body = JSON.parse(json_string) if json_string && !json_string.empty?
      rescue JSON::ParserError
        return {}
      end
      body
    end