Quantcast
Channel: Microsoft Dynamics CRM
Viewing all articles
Browse latest Browse all 137182

Forum Post: Deserialize in Dynamics 365 CRM - JSON string to .NET object

$
0
0
Hi, I am trying to deserialize JSON string to .NET object in a plugin.I am using DataContractJsonSerializer as JavaScriptSerializer has security issues. But , still I am facing below error. Error Message : Type 'UpdateOpportunitiesFromIntegration.jsondataclass' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. If the type is a collection, consider marking it with the CollectionDataContractAttribute. See the Microsoft .NET Framework documentation for other supported types. Code : string jsonobject = entity.Attributes["ae_operativeintegrationobject"].ToString(); using (System.IO.MemoryStream DeserializeStream = new System.IO.MemoryStream()) { DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(jsondataclass)); System.IO.StreamWriter writer = new System.IO.StreamWriter(DeserializeStream); writer.Write(jsonobject); writer.Flush(); DeserializeStream.Position = 0; jsondataclass deserializeobj = (jsondataclass)serializer.ReadObject(DeserializeStream); } Class file added to solution : class jsondataclass { public string SalesOrderId { get; set; } public string SalesOrderName { get; set; } public string SalesOrderStage { get; set; } public string OrderStartDate { get; set; } public string OrderEndDate { get; set; } public string TotalOrderValue { get; set; } }

Viewing all articles
Browse latest Browse all 137182

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>