Remove concrete __type information in JSON Response using JsonSerializer

半城伤御伤魂 提交于 2019-12-05 15:03:48

问题


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


回答1:


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;


来源:https://stackoverflow.com/questions/12731214/remove-concrete-type-information-in-json-response-using-jsonserializer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!