Method: Cloudinary::Utils.json_decode

Defined in:
lib/cloudinary/utils.rb

.json_decode(str) ⇒ Object



923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
# File 'lib/cloudinary/utils.rb', line 923

def self.json_decode(str)
  if !@@json_decode
    @@json_decode = true
    begin
      require 'json'
    rescue LoadError
      begin
        require 'active_support/json'
      rescue LoadError
        raise LoadError, "Please add the json gem or active_support to your Gemfile"
      end
    end
  end
  defined?(JSON) ? JSON.parse(str) : ActiveSupport::JSON.decode(str)
end