Port flat string JSON responses with HttpUtility encoding
ProprietaryOpt-in default-encoder/declaration-order port of fresh parameterless JavaScriptSerializer.Serialize calls on flat anonymous objects with explicit ASCII property names and resolved string values. Capture values once in order in a private helper, retain null/string JSON representation with HttpUtility.JavaScriptStringEncode, and enforce the default MaxJsonLength with InvalidOperationException and its English message. Assume default Framework HttpEncoder; custom encoder configuration, localization, reflection property order and allocation identity are not emulated. Leave configured/custom serializers, other value types/shapes/overloads, named calls, comments, aliases/scoped imports, lambdas/queries, partial/generic owners and snapshots unchanged. Separate from version upgrades; target .NET Core 3.0 or later.
OpenRewrite. Recipes. CSharp. Migration. Dotnet. Net3_0. UseHttpUtilityForFlatStringJsonResponsesmod run . --recipe= OpenRewrite. Recipes. CSharp. Migration. Dotnet. Net3_0. UseHttpUtilityForFlatStringJsonResponsesInstall it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.