Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json AWS Lambda和API网关上的Dotnet核心_Json_.net Core - Fatal编程技术网

Json AWS Lambda和API网关上的Dotnet核心

Json AWS Lambda和API网关上的Dotnet核心,json,.net-core,Json,.net Core,我是AWS Lambda使用Dotnet Core的新手。我在VisualStudio上使用AWS Lambda项目(.NET Core)创建了新的项目模板。函数HelloWorld非常基本,只返回大写 using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Amazon.Lambda.Core; // Assembly attribute t

我是AWS Lambda使用Dotnet Core的新手。我在VisualStudio上使用AWS Lambda项目(.NET Core)创建了新的项目模板。函数HelloWorld非常基本,只返回大写

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

using Amazon.Lambda.Core;

// Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class.
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))]

namespace HelloWorld
{
    public class Function
    {

        /// <summary>
        /// A simple function that takes a string and does a ToUpper
        /// </summary>
        /// <param name="input"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public string FunctionHandler(string input, ILambdaContext context)
        {
            return input?.ToUpper();
        }
    }
}

我在visualstudio上使用AWSToolkitPackage运行测试,它可以工作!因为输入参数是字符串。但在《邮递员》上,我也试着放了一根绳子,但没用。。。有人有这方面的经验吗?非常感谢。

您错过了这一行

using Amazon.Lambda.Serialization;
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))]
没有那条线,这条线

using Amazon.Lambda.Serialization;
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))]

实际上不起作用

您缺少这一行

using Amazon.Lambda.Serialization;
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))]
没有那条线,这条线

using Amazon.Lambda.Serialization;
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))]

真的不行

啊!!!!我找到了解决办法。不要使用“字符串”,而是使用“JObject”

啊!!!!我找到了解决办法。用“JObject”代替“string”,你能在lambda中发布你所有的代码吗?你好,我更新了完整的代码。谢谢你能在你的lambda中发布你所有的代码吗?你好,我更新了完整的代码。谢谢,它不起作用了。。。我用VS测试过,它可以工作,但用PostMan测试就不行了。我认为,因为在VS中,他们允许将参数作为“字符串”输入,但邮递员将参数作为“json”传递,所以我认为……这不起作用。。。我用VS测试过,它可以工作,但用PostMan测试就不行了。我认为,因为在VS中,他们允许将参数作为“字符串”输入,但邮递员将参数作为“json”传递,我认为。。。