Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amazon.Lambda.Serialization.SystemTextJson.LambdaJsonSerializer options customizations ignore when in debug mode #628

Closed
rpopovych opened this issue Apr 17, 2020 · 3 comments
Labels
bug This issue is a bug.

Comments

@rpopovych
Copy link

rpopovych commented Apr 17, 2020

I am trying to use custom serialization options in the new Amazon.Lambda.Serialization.SystemTextJson.LambdaJsonSerializer. It looks like they are ignored in Debug mode (LAMBDA_NET_SERIALIZER_DEBUG = true).

public class LambdaSerializer : Amazon.Lambda.Serialization.SystemTextJson.LambdaJsonSerializer
{
    public LambdaSerializer() : base(Customizer) { }

    private static void Customizer(JsonSerializerOptions options)
    {
        options.Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping;
    }
}

JsonSerializer.Serialize(utf8Writer, response);
var jsonDocument = debugWriter.ToString();
Console.WriteLine($"Lambda Serialize {response.GetType().FullName}: {jsonDocument}");
var writer = new StreamWriter(responseStream);
writer.Write(jsonDocument);
writer.Flush();
}
}
else
{
using (var writer = new Utf8JsonWriter(responseStream))
{
JsonSerializer.Serialize(writer, response, _options);

@normj
Copy link
Member

normj commented Apr 19, 2020

I'm addressing this issue with this PR #636 that also addressing the camel casing issue.

@normj
Copy link
Member

normj commented Apr 28, 2020

Version 2.0.0 of Amazon.Lambda.Serialization.SystemTextJson is out with the change. Main take away it update the serializer class to be DefaultLambdaJsonSerializer.

I also published a blog post that has a section describing the change.
https://aws.amazon.com/blogs/developer/one-month-update-to-net-core-3-1-lambda/

@rpopovych
Copy link
Author

Thank you!

@normj normj closed this as completed Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug.
Projects
None yet
Development

No branches or pull requests

2 participants