Skip to content

Instantly share code, notes, and snippets.

@gistlyn
Created February 2, 2023 11:26
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 gistlyn/031775083362f86b6973a96c1aa94bc3 to your computer and use it in GitHub Desktop.
Save gistlyn/031775083362f86b6973a96c1aa94bc3 to your computer and use it in GitHub Desktop.
json-empty-lists
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<OutputType>Exe</OutputType>
<NoWarn>1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ServiceStack.Common" Version="6.*" />
</ItemGroup>
</Project>
using ServiceStack;
using ServiceStack.Text;
Console.WriteLine(new Test().ToJson()); //Prints {"List":[]}
public class Test
{
public List<string> List { get; set; } = new();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment