Justin T. Watts
Justin T. Watts

Reputation: 565

ServiceStack Deserializing

I'm able to get ServiceStack to serialize my objects but deserializing is another story. I'm receiving this json:

{
   "Return": {
       "A":15,
       "B":16,
       "Result":240
   },
   "Time":0.0743458271027
}

And I want to deserialize it to this class type:

public class Result<T>
{
    public T Return;
    public double Time;
}

which T in this case is Math:

public class Math
{
    public int A;
    public int B;
    public int C;
    public decimal Result;
}

I've used Newtonsoft.Json and all is well, but ServiceStack should be 3 times faster but I just get objects with no values.

Upvotes: 1

Views: 489

Answers (1)

mythz
mythz

Reputation: 143399

By default ServiceStack text serializers doesn't serialize public fields, but you can enable them with:

JsConfig.IncludePublicFields = true;

Upvotes: 2

Related Questions