Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Don't raise a TypeError when trying to parse nil as JSON.
Fixes an issue where when some API's return a 204 response for an empty page of
a collection endpoint ActiveResource blows up with a TypeError because it's
unable to parse the 'nil' response body as JSON.
  • Loading branch information
undergroundwebdesigns committed Jun 15, 2017
1 parent 62d7c8d commit dd93930
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/active_resource/formats/json_format.rb
Expand Up @@ -18,6 +18,7 @@ def encode(hash, options = nil)
end

def decode(json)
return nil if json.nil?
Formats.remove_root(ActiveSupport::JSON.decode(json))
end
end
Expand Down

0 comments on commit dd93930

Please sign in to comment.