Created
December 2, 2016 03:15
-
-
Save guitarrapc/e6cae2690cf85cd81c391f18717df7b0 to your computer and use it in GitHub Desktop.
JSON Input Convert to MyClass sample for Lambda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using Amazon.Lambda.Core; | |
using Amazon.Lambda.Serialization; | |
// Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class. | |
[assembly: LambdaSerializerAttribute(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))] | |
namespace AWSLambda1 | |
{ | |
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 SampleClass FunctionHandler(SampleClass input, ILambdaContext context) | |
{ | |
var response = new SampleClass | |
{ | |
Str = input.Str?.ToUpper(), | |
StrArray = input.StrArray.Select(x => x?.ToUpper()).ToArray(), | |
}; | |
return response; | |
} | |
} | |
public class SampleClass | |
{ | |
public string Str { get; set; } | |
public string[] StrArray { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment