ServiceStack.Text json only serialize struct properties

萝らか妹 提交于 2019-12-11 06:23:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!