Documentation > CMS Template API Library > DataContractSerializer

CrownPeak.CMSAPI.Experimental.DataContractSerializer

Experimental methods. They could change in a future release. Use at your own risk. You can use [DataContract] to tag serializable classes. Use [DataMember] on properties and [EnumMember] for enums. These classes have the advantage that you can use them for Xml or JSON, but they are not as flexible for the Xml.

NameDescriptionType
DeserializeJson

WARNING Experimental. It could change in a future release. Use at your own risk. Define a class that uses [DataContract], [DataMember], and [EnumMember] tags and you can then create an object from a json representation of the object with this method Use the Name property in the DataMember to use a name that is different from the property name -- [DataContract(Name="MySpecialName")] Use the Namespace in the DataContract to use a namespace that is custom for XML -- [DataContract(Namespace = "MySpecialNamespace")]

Method
DeserializeXml

WARNING Experimental. It could change in a future release. Use at your own risk. Define a class that uses [DataContract], [DataMember], and [EnumMember] tags and you can then create an object from a xml representation of the object with this method Use the Name property in the DataMember to use a name that is different from the property name -- [DataContract(Name="MySpecialName")] Use the Namespace in the DataContract to use a namespace that is custom for XML -- [DataContract(Namespace = "MySpecialNamespace")]

Method
SerializeJson

WARNING Experimental. It could change in a future release. Use at your own risk. Define a class that uses [DataContract], [DataMember], and [EnumMember] tags and you can then serialize an instance of that class to JSON with this method Use the Name property in the DataMember to use a name that is different from the property name -- [DataContract(Name="MySpecialName")] Use the Namespace in the DataContract to use a namespace that is custom for XML -- [DataContract(Namespace = "MySpecialNamespace")]

Method
SerializeXml

WARNING Experimental. It could change in a future release. Use at your own risk. Define a class that uses [DataContract], [DataMember], and [EnumMember] tags and you can then serialize an instance of that class to XML with this method Use the Name property in the DataMember to use a name that is different from the property name -- [DataContract(Name="MySpecialName")] Use the Namespace in the DataContract to use a namespace that is custom for XML -- [DataContract(Namespace = "MySpecialNamespace")]

Method

Connect with Crownpeak