fun <T : Any> String.serializerSafe(serializer: KSerializer<T>?): String
Ensures a JSON string is safe for the given serializer.