Skip to content

Instantly share code, notes, and snippets.

@guitarrapc
Created December 2, 2016 03:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guitarrapc/e6cae2690cf85cd81c391f18717df7b0 to your computer and use it in GitHub Desktop.
Save guitarrapc/e6cae2690cf85cd81c391f18717df7b0 to your computer and use it in GitHub Desktop.
JSON Input Convert to MyClass sample for Lambda
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