Remove concrete __type information in JSON Response using JsonSerializer
Asked Answered
H

1

13

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

Hildagarde answered 4/10, 2012 at 16:0 Comment(0)
L
23

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;
Lillie answered 4/10, 2012 at 16:9 Comment(3)
Thanks!! Always a pleasure working with this framework mythz.Hildagarde
How and where should I set it? At Service implementation? At AppHostBase.Configure()?Magnanimity
Nevermind, I found it. Thanks! github.com/ServiceStack/ServiceStack/wiki/Configuration-optionsMagnanimity

© 2022 - 2024 — McMap. All rights reserved.