Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove concrete __type information in JSON Response using JsonSerializer

How do you force the __type information from rendering in the deserialized JSON response? I have no need to reserialize this data so I'd prefer to remove it. ServiceStack seems to add this to the dictionary properties of my model.

This is using ServiceStack and ServiceStack.Text.JsonSerializer

like image 569
Steve Stevenson Avatar asked Oct 04 '12 16:10

Steve Stevenson


1 Answers

By default the __type is only emitted when it's required for deserialization, e.g. your DTO contains an interface, abstract class or late-bound object type, etc.

You can prevent it from ever being emitted with:

JsConfig.ExcludeTypeInfo = true;

Otherwise you can always emit it with:

JsConfig.IncludeTypeInfo = true;
like image 103
mythz Avatar answered Nov 15 '22 08:11

mythz