ServiceStack.Text json仅序列化结构属性 [英] ServiceStack.Text json only serialize struct properties

查看:122
本文介绍了ServiceStack.Text json仅序列化结构属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以像.net JavaScriptSerializer一样使ServiceStack.Text消毒结构的公共字段?

Is it possible to make ServiceStack.Text sterilize public fields of a struct just like the .net JavaScriptSerializer does?

当前,如果结构未将文件定义为属性,即c ++或get; set;中的property关键字;在C#中,该值未序列化.

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.

推荐答案

ServiceStack序列化程序当前无法实现.

根据设计,ServiceStack序列化程序会尝试促进在服务的服务层/边界中使用特殊用途的DTO,在此目标中,我们仅序列化类型的公共属性,从而可以灵活地生成有线格式.

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).

这篇关于ServiceStack.Text json仅序列化结构属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆