We are using AWS SWF and SQS, for passing data, SS.Text is used to serialize objects to string.
Some of the same POCO’s are exposed through our public web service.
I need SS.Text to serialize all properties (for internal use), but, I only want the SS web service to serialise some of the properties in the response.
If I wanted SS.Text to exclude properties, it would be simple (JsConfig<ClassName>.ExcludePropertyNames), but how do I get the SS web service to exclude properties while my usage of SS.Text serializes all properties?
Dan Barua:
I would have different POCO DTOs for internal and public facing and use internal.TranslateTo<ExternalDto>()
If that’s not to your taste you could take a look at this project here that implements partial responses (returning a limited subset of fields): https://github.com/AnthonyCarl/ServiceStack.PartialResponse
You can also use a JsConfig config block to scope changes that only apply within that scope, e.g: https://github.com/ServiceStack/ServiceStack.Text/blob/master/tests/ServiceStack.Text.Tests/AdhocModelTests.cs#L358-L369
Michael Daly:
Thanks. Will have a look tomorrow.
Stephen Brannan:
I had a similar situation here and what we did is wrapped the SS.Text serializer in our own serializer by extending it via the JsonObject in SS.Text. Our need was to provide a way for our end users to add properties dynamically even though they were not on the typed DTOs.
I have a similar need to have DTO’s come in from SQS but they could be missing some fields. Right now I get an exception that strings cannot be null (on fields that are in fact there but empty) and also I know we’ll need to ignore fields that are missing.
Suggestions welcome…