Should JsConfig.IncludeTypeInfo work within scopes

Hi

I’ve tried using JsConfig.With to create a scope to include type info in the JSON string.
However it doesn’t seem to work. Should it?

The following .NET 8, SS 8.4.0 example demonstrates the problem. In this example every JSON string looks the same - none include the type info.

using ServiceStack.Text;

JsConfig.IncludeTypeInfo = false;

var cus = new Customer { Name = "Dave" };

Console.WriteLine(JsonSerializer.SerializeToString(cus));

using (JsConfig.With(new Config { IncludeTypeInfo = true }))
{
    Console.WriteLine(JsonSerializer.SerializeToString(cus));
}

Console.WriteLine(JsonSerializer.SerializeToString(cus));

Console.ReadKey();

public class Customer
{
    public string Name { get; set; }
}


This should now be fixed from this commit.

This change is available from v8.4.1+ that’s now available in the pre release packages.

1 Like

Thanks for the fast turnaround :slight_smile: