当我尝试访问任何像下面所示的代码那样构建的 API 端点时,我收到以下运行时错误:
ArgumentException: Invalid type parameter
'Microsoft.AspNetCore.Mvc.JsonResult' specified for 'ActionResult<T>'.
Run Code Online (Sandbox Code Playgroud)

此代码在 .NET Core 2.1 中的应用程序中按预期运行。升级到 .NET Core 2.2 后,这个问题就被打破了。
这是控制器中我的一个端点的代码。
[HttpGet]
public async Task<ActionResult<JsonResult>> Get()
{
try
{
MongoConnector mongo = new
MongoConnector(_configService.GetMongoConnectionString());
List<BsonDocument> queues = await mongo.AggregateQueues(
(aggregator) => aggregator
.Match(CommonAggregation.SinceYesterday)
.Sort(CommonAggregation.SortByDate)
.Group(QueueAggregators.GroupQueuesByMessagingName)
);
List<QueueHealth> queueHealth = await MongoConnector.DeserializeList<QueueHealth>(queues);
JsonResult result = new JsonResult(queueHealth);
result.Value = queueHealth;
result.ContentType = "application/json";
result.StatusCode = 200;
return result;
}
catch (Exception ex)
{
logger.Error(ex, "An exception was thrown within /api/MessageQueue");
return …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用in和not in运算符以及Accumulator Pattern来删除字符串中的所有重复字母,并在保持顺序的同时返回一个新字符串.
withDups = "The Quick Brown Fox Jumped Over The Lazy Dog"
def removeDups(s):
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
sWithoutDups = ""
for eachChar in withDups:
if eachChar in alphabet:
sWithoutDups = eachChar + sWithoutDups
return sWithoutDups
print(removeDups(withDups))
Run Code Online (Sandbox Code Playgroud)
我当前的代码只返回字符串的第一个字母.我对python和编码一般都是新手,所以请原谅我是否忽略了一些简单的东西,我现在的代码甚至不是正确的方向,或者我发布了一些不应该发布的东西.