diff options
Diffstat (limited to 'activesupport/lib/active_support/json/decoding.rb')
-rw-r--r-- | activesupport/lib/active_support/json/decoding.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/json/decoding.rb b/activesupport/lib/active_support/json/decoding.rb index 72fd97ceee..e44939e78a 100644 --- a/activesupport/lib/active_support/json/decoding.rb +++ b/activesupport/lib/active_support/json/decoding.rb @@ -39,6 +39,14 @@ module ActiveSupport self.backend = old_backend end + # Returns the class of the error that will be raised when there is an error in decoding JSON. + # Using this method means you won't directly depend on the ActiveSupport's JSON implementation, in case it changes in the future. + # + # begin + # obj = ActiveSupport::JSON.decode(some_string) + # rescue ActiveSupport::JSON.parse_error + # Rails.logger.warn("Attempted to decode invalid JSON: #{some_string}") + # end def parse_error MultiJson::DecodeError end |