Skip to content

Commit

Permalink
Fixes support for Oj < 3.3.3 (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefansedich authored and iMacTia committed Aug 2, 2017
1 parent 693ee0d commit 52ca881
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/faraday_middleware/response/parse_json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ParseJson < ResponseMiddleware
end

define_parser do |body, parser_options|
::JSON.parse(body, parser_options) unless body.strip.empty?
::JSON.parse(body, parser_options || {}) unless body.strip.empty?
end

# Public: Override the content-type of the response with "application/json"
Expand Down
6 changes: 1 addition & 5 deletions lib/faraday_middleware/response_middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@ def process_response(env)
def parse(body)
if self.class.parser
begin
if @parser_options
self.class.parser.call(body, @parser_options)
else
self.class.parser.call(body)
end
self.class.parser.call(body, @parser_options)
rescue StandardError, SyntaxError => err
raise err if err.is_a? SyntaxError and err.class.name != 'Psych::SyntaxError'
raise Faraday::Error::ParsingError, err
Expand Down

0 comments on commit 52ca881

Please sign in to comment.