Reputation: 654
As the title says, is there a way to keep empty lists during JSON serialization in ServiceStack?
Upvotes: 0
Views: 33
Reputation: 143409
ServiceStack.Text JSON Serializer, already serializes empty lists by default:
using ServiceStack;
using ServiceStack.Text;
Console.WriteLine(new Test().ToJson());
public class Test
{
public List<string> List { get; set; } = new();
}
Output:
{"List":[]}
Upvotes: 1