kost/nessus_rest-ruby · nessus_rest.rb
ruby logo
def parse_json(body)
      buf = {}

      begin
        buf = JSON.parse(body)
      rescue JSON::ParserError
      end

      buf
    end
Similar code snippets
1.
xing/xing_api · response_handler.rb
Match rating: 62.01% · See similar code snippets
ruby logo
def parse_json(response)
      JSON.parse(response.body.to_s, symbolize_names: true)
    rescue JSON::ParserError
      { message: response.body.to_s }
    end
2.
ScreenStaring/recharge-api · http_request.rb
Match rating: 59.09% · 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
3.
myfreecomm/rexpense-client-ruby · response.rb
Match rating: 57.42% · See similar code snippets
ruby logo
def parsed_body(key = nil)
      return JSON.parse(body)[key] unless key.nil?
      JSON.parse(body)
    rescue JSON::ParserError
      {}
    end
4.
iZettle/api-blueprint · parser.rb
Match rating: 57.09% · See similar code snippets
ruby logo
def parse(body)
      body.is_a?(String) ? JSON.parse(body) : body
    rescue JSON::ParserError
      {}
    end
5.
estiens/nanoleaf_ruby · base_requester.rb
Match rating: 56.9% · 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
6.
soracom/soracom-sdk-ruby · api_client.rb
Match rating: 56.54% · See similar code snippets
ruby logo
def parse(response)
      begin
        return JSON.parse(response)
      rescue JSON::ParserError => e
        return {result: response}
      end
    end
7.
richard-viney/ig_markets · session.rb
Match rating: 55.29% · See similar code snippets
ruby logo
def parse_body(response)
      return {} if response.body == ''

      ResponseParser.parse JSON.parse(response.body)
    rescue JSON::ParserError
      raise Errors::InvalidJSONError, response.body
    end
8.
Katello/katello_api · base.rb
Match rating: 54.71% · 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
9.
soulim/oembed · parser.rb
Match rating: 53.25% · See similar code snippets
ruby logo
def json(body)
      begin
        JSON.parse(body)
      rescue JSON::JSONError => e
        raise Oembed::ParserError.new(e), 'JSON parser error'
      end
    end
10.
cbetta/doxie · client.rb
Match rating: 53.0% · See similar code snippets
ruby logo
def parse_json(response)
      if response['Content-Type'].split(';').first == 'application/json'
        JSON.parse(response.body)
      else
        response.body
      end
    end