--- Encode/compress

Compress.Encode = function(str)
	--- Vars
	local convertedToJSON = false
	
	--- Convert table to JSON
	if type(str) == "table" then
		--- Attempt to conver to JSON
		local success = pcall(function()
			str = _L.Services.HttpService:JSONEncode(str)
			convertedToJSON = true
		end)
		
		--- Failed to encode to JSON (userdata or empty?)
		if (not success) or (not str) then
			_L.Print("Failed to convert table to string", true)
			return
		end
	end
	
	--- Compress string
	local encoded = Encode(str)
	if utf8.len(str) > utf8.len(encoded) then

		--- Successfully compressed
		return encoded
	else

		--- Size of compressed string larger than original
		return str, convertedToJSON
	end
end

