class HashSerializer
  def self.dump(str)
    JSON.parse str
  end

  def self.load(hash)
    return '{}' if hash.nil?
    hash.empty? ? '{}' : hash.to_json
  end
end

class HashSerializer
  def self.dump(str)
    JSON.parse str
  end

  def self.load(hash)
    return '{}' if hash.nil?
    hash.empty? ? '{}' : JSON.dump(hash)
  end
end

Switch to JSON.dump for hash serialization
Switch to JSON.dump for hash serialization