Deserialization problem in webservice

Hi,

I am just began to convert my existing webservices to ServiceStack ones.
But I am facing a problem with deserialization of objects. There is no problem in basic types like string,int …

I have a “Query” class as shown below;

And I have a servicemodel like;

And When I try to invoke webservice, with “http://localhost:64378/eqapi/v1/datar?format=json” and payload like;

{“name”:“q1-3433”,
“query”:{“table”:“q1-3433”}
}

As you can see below, it deserialize an query object;

But without fields …

What is my problem?
I created the project using VS ServiceStack Project Template…

By default ServiceStack Text serializers only serialize public properties, you can tell ServiceStack to serialize public fields with:

JsConfig.IncludePublicFields = true;

But I’d strongly recommend that you use public properties in all your POCOs so the models can be used throughout all ServiceStack libraries, e.g:

public class Query
{
    public string table { get; set; } //add getters/setters
}

Thank you very much for your really fast and clear response.

1 Like