json-serialization
Skill0 starsChanged 10 days agoMITView on GitHub
How this Lambda function reads and writes JSON - the assembly-level LambdaFunctionJsonSerializer with camelCase names, the source-generated LambdaFunctionJsonSerializerContext, which types it must list, and how JSON is shaped. Use when adding a request or response type, changing how JSON looks, or when a value serialises differently than expected.
4 other projects use a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- LeanMeanCleanApps/CleanWebApitheir own version, first seen Nov 15, 2026
- LeanMeanCleanApps/CleanMinimalApiedited, first seen Nov 15, 2026
- LeanMeanCleanApps/CleanModelContextProtocoltheir own version, first seen Nov 8, 2026
- bkywksj/knowledge-basetheir own version, first seen Oct 8, 2026
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 1
- LeanMeanCleanApps/CleanMinimalApi★ 40012% same
Wrote their own version · 3
- bkywksj/knowledge-base★ 340same name
- LeanMeanCleanApps/CleanWebApi★ 4same name
- LeanMeanCleanApps/CleanModelContextProtocol★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository40 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- add-a-use-caseSkill
- api-conventionsSkill
- branches-and-pull-requestsSkill
- cancellationSkill
- ci-for-your-solutionSkill
- ci-pipelineSkill
- clean-architecture-layersSkill
- configuration-and-environmentsSkill
- coverageSkill
- csharp-house-styleSkill
- data-access-ef-coreSkill
- database-migrationsSkill
- docker-and-composeSkill
- docs-and-voiceSkill
- errors-and-exceptionsSkill
- expose-a-use-caseSkill
- family-syncSkill
- health-checksSkill
- integration-testsSkill
- lambda-emulatorSkill
- mapping-with-mapperlySkill
- mediatorSkill
- optional-token-authSkill
- packages-and-dependenciesSkill
- pagingSkill
- presentation-integration-testsSkill
- releasesSkill
- sample-dataSkill
- security-findingsSkill
- serilogSkill
- telemetrySkill
- template-authoringSkill
- test-designSkill
- time-providerSkill
- unit-testsSkill
- validationSkill
- writing-a-skillSkill
- xml-docs-and-openapiSkill
The file
We split this skill into the rules it gives an agent
4 rules. 0 are common, 1 is distinctive, and 3 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 25
Add every new request and response type to LambdaFunctionJsonSerializerContext with [JsonSerializable(typeof(...))], including each Page<T> …
- Distinctive: line 27
Add a serializer test for a new request type (it reads the JSON a caller sends) and for any response whose shape matters to callers.
- Very specific: line 46
Use [JsonPropertyName] to rename one property.
- Very specific: line 47
Use Newtonsoft.Json or Amazon.Lambda.Serialization.Json.
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
JSON serialization (Lambda function)
The rule
Lambda hands the function a JSON payload and expects JSON back. The [assembly: LambdaSerializer(...)] attribute at the top of LambdaFunction.cs sets the serializer for every function: LambdaFunctionJsonSerializer in src/Presentation/LambdaFunction/Serialization/. It's a SourceGeneratorLambdaJsonSerializer<LambdaFunctionJsonSerializerContext> from Amazon.Lambda.Serialization.SystemTextJson that writes camelCase, like the other templates. It uses the source-generated metadata in src/Presentation/LambdaFunction/Serialization/LambdaFunctionJsonSerializerContext.cs, so nothing is serialised with reflection, which keeps cold starts short.
| Behaviour | Effect |
| Property names read in any case | {"query":"star"} and {"Query":"star"} both fill Query |
| Property names written in camelCase | Responses read items, totalCount, nextOffset |
| Nulls left out | NextOffset disappears on the last page, AverageStars when there are no reviews |
| Only listed types | A type missing from the context can't be serialised |
Responses are trees: a list returns flat records, and a review holds a flat Movie and a flat Author. There's no cycle handling.
Steps
- Add every new request and response type to
LambdaFunctionJsonSerializerContextwith[JsonSerializable(typeof(...))], including eachPage<T>you return. The HTTP API functions also needProblem,APIGatewayHttpApiV2ProxyRequestandAPIGatewayHttpApiV2ProxyResponse, which are already there. - Change how JSON looks in the
LambdaFunctionJsonSerializerconstructor, not on single properties, and keep the request and response tests intests/Presentation.Tests.Unit/Serialization/LambdaFunctionJsonSerializerTests.csin step. The serializer's own options replace the context's, so[JsonSourceGenerationOptions]on the context has no effect. - Add a serializer test for a new request type (it reads the JSON a caller sends) and for any response whose shape matters to callers.
Example
// src/Presentation/LambdaFunction/Serialization/LambdaFunctionJsonSerializerContext.cs
[JsonSerializable(typeof(ListRequest))]
[JsonSerializable(typeof(ListReviewsRequest))]
[JsonSerializable(typeof(Page<Movie>))]
[JsonSerializable(typeof(Page<Author>))]
[JsonSerializable(typeof(Page<Review>))]
public partial class LambdaFunctionJsonSerializerContext : JsonSerializerContext
{
}Don't
- Switch to
DefaultLambdaJsonSerializerorCamelCaseLambdaJsonSerializer. They use reflection and slow every cold start. - Use
[JsonPropertyName]to rename one property. - Use Newtonsoft.Json or
Amazon.Lambda.Serialization.Json. - Let a response type refer back to its parent.
Check
dotnet test tests/Presentation.Tests.Unit --filter "FullyQualifiedName~Serializer"Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

