Oguz Karadenizli
Oguz Karadenizli

Reputation: 3505

One time json serialization with type info in ServiceStack

We can set serialization settings via JsConfig in ServiceStack.

JsConfig.IncludeTypeInfo = true;

But we want to user Json serializing without "Type Info" except one place. So how can we serialize with type info at there.

I think we need optional config parameter:

JsonSerializer.SerializeToString(x,**JsConfig**)

Upvotes: 1

Views: 128

Answers (1)

kampsj
kampsj

Reputation: 3149

You can use a scope for only the place you need the type information:

using (JsConfig.With(new Config { IncludeTypeInfo = true }))
{
    var json = new DTO().ToJson();
}

Upvotes: 3

Related Questions