soulim/oembed · parser.rb
ruby logo
def json(body)
      begin
        JSON.parse(body)
      rescue JSON::JSONError => e
        raise Oembed::ParserError.new(e), 'JSON parser error'
      end
    end
Similar code snippets
1.
soracom/soracom-sdk-ruby · api_client.rb
Match rating: 64.86% · See similar code snippets
ruby logo
def parse(response)
      begin
        return JSON.parse(response)
      rescue JSON::ParserError => e
        return {result: response}
      end
    end
2.
richard-viney/ig_markets · session.rb
Match rating: 61.48% · 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
3.
rsinger/RDFObjects · parsers.rb
Match rating: 61.0% · See similar code snippets
ruby logo
def data=(json)
      if json.is_a?(String)
        @json = JSON.parse(json)
      elsif json.is_a?(Hash)
        @json = json
      elsif json.respond_to?(:read)
        @json = JSON.parse(json.read)
      end
    end
4.
ScreenStaring/recharge-api · http_request.rb
Match rating: 60.73% · 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
5.
puppetlabs/bolt · bolt_option_parser.rb
Match rating: 60.08% · See similar code snippets
ruby logo
def parse_params(params)
      json = get_arg_input(params)
      JSON.parse(json)
    rescue JSON::ParserError => e
      raise Bolt::CLIError, "Unable to parse --params value as JSON: #{e}"
    end
6.
travis-ci/travis-core · formats.rb
Match rating: 59.94% · See similar code snippets
ruby logo
def normalize_json(json)
      json = json.to_json unless json.is_a?(String)
      JSON.parse(json)
    end
7.
xing/xing_api · response_handler.rb
Match rating: 58.98% · 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
8.
wjdhamilton/easy-json-matcher · json_coercer.rb
Match rating: 58.8% · 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
9.
gstark/tesla-api · private_api.rb
Match rating: 58.56% · See similar code snippets
ruby logo
def get_json(uri, options = {})
      check_logged_in!

      response = get(uri, options)

      [response, JSON.parse(response.body)]
    rescue JSON::ParserError => e
      raise Errors::InvalidJSON.new(e)
    end
10.
hidroh/cucumber-api · response.rb
Match rating: 58.52% · See similar code snippets
ruby logo
def has json_path, json=nil
      if json.nil?
        json = JSON.parse body
      end
      not JsonPath.new(json_path).on(json).empty?
    end