问题
Is it possible to make ServiceStack.Text sterilize public fields of a struct just like the .net JavaScriptSerializer does?
Currently if a struct does not define a filed as a property, i.e. property keyword in c++ or get;set; in c# the value does not get serialized.
回答1:
This is not currently possible with ServiceStack serializers.
By design ServiceStack serializers tries to promote the use of special purpose DTOs for use in the service layer/boundary of your services, in this goal we only serialize public properties of types which allows flexibility in how the wire format is generated.
This is opposed to being a general purpose object serializer that would also serialize the internal representation of your types (i.e. private and public fields).
来源:https://stackoverflow.com/questions/14494677/servicestack-text-json-only-serialize-struct-properties