Marco Siffert
Marco Siffert

Reputation: 555

How to force ServiceStack to serialize an object

I am declaring my reponse-dto like this:

[Route("/activity/sync", HttpVerb.Get)]
public class SyncActivityRequest : IReturn<SyncActivityResponse>
{
    public ICollection<SyncParam> ObjectsToSync { get; set; }
}

public class SyncActivityResponse
{
    public ICollection<KeyValuePair<Activity, SyncMetadata>> Result { get; set; }
}

The problem is ServiceStack does not serialize Activity and SyncMetadata because those are only type-arguments for another object (KeyValuePair in this case). Those two objects (activity and syncmetadata) both are declared in the same project.

How can I force the serialization of those two objects?

Thanks!

Upvotes: 1

Views: 32

Answers (1)

mythz
mythz

Reputation: 143284

You should avoid using interfaces or objects in DTOs, use a concrete Type like List<T> or T[] instead.

Upvotes: 1

Related Questions