0

I'm using ServiceStack.Text's Dump() method to make strings out objects for debugging/logging/etc purposes. Is there any way to exclude specific fields from the object from Dump() showing? Hoping there is a simpler way short of making stripped down versions of my same objects and then Automapping and Dump()'ing the 'lite' versions...

Note, I'm still using the last free ServiceStack.Text v3.7 or what not, but would be willing to pay for the new version if it can do this and the old version can't.

Jeremy
  • 388
  • 1
  • 4
  • 12
  • You could use the `IgnoreDataMember` attribute but this will **impact all serialization** (ie `.ToJson()`). I think you might have to go with making stripped down Classes. ServiceStack's extensions methods (see AutoMappingUtils.cs) should make mapping easier. Look into `.ConvertTo<>()` and `.PopulateWith` – paaschpa Feb 18 '15 at 23:21

1 Answers1

1

You can look at this existing Question on the different ways to ignore properties during Serialization in ServiceStack's Text Serializers.

Community
  • 1
  • 1
mythz
  • 141,670
  • 29
  • 246
  • 390
  • All of those methods seem to be set in stone, what about only ignoring certain fields only sometimes? Basically just want to exclude certain fields, but only sometimes. ShouldSerialize() couldn't tell which is which just based on just the fieldname. Is there any way to make the change to JsConfig.ExcludePropertyNames apply to a local scope only? Thanks! – Jeremy Feb 19 '15 at 15:54
  • @Jeremy The last option i.e. `ShouldSerialize()` lets you dynamically specify whether to deserialize a property or not, otherwise you can just set the property to null. – mythz Feb 19 '15 at 16:24