From IT Skills
Jump to: navigation, search
(marking properties)
(marking properties)
 
Line 15: Line 15:
 
[https://stackoverflow.com/questions/7693391/nonserialized-on-property As of .NET 3.0, you can use DataContract instead of Serializable. With the DataContract though, you will need to either "opt-in" by marking the serializable fields with the DataMember attribute; or "opt-out" using the IgnoreDataMember... opt-out by default will only serialize public members, while opt-in will only serialize the marked members (regardless of protection level)]
 
[https://stackoverflow.com/questions/7693391/nonserialized-on-property As of .NET 3.0, you can use DataContract instead of Serializable. With the DataContract though, you will need to either "opt-in" by marking the serializable fields with the DataMember attribute; or "opt-out" using the IgnoreDataMember... opt-out by default will only serialize public members, while opt-in will only serialize the marked members (regardless of protection level)]
  
Wcf is synchronized by [[Typewriter]]
+
opt-in is turned on when class marked by DataContract
 +
 
 +
Wcf uses [[Typewriter]]
  
 
Newtonsoft.Json uses JsonProperty, JsonIgnore attributes.
 
Newtonsoft.Json uses JsonProperty, JsonIgnore attributes.

Latest revision as of 16:38, 12 August 2019

How deserialize JSON[edit | edit source]

in dotNet[edit | edit source]

  • from System.Runtime.Serialization.dll by JsonReaderWriterFactory or DataContractJsonSerializer (faster than JavaScriptSerializer)
  • from System.Web.Extensions.dll by JavaScriptSerializer
  • from System.Web.Helpers.dll by Json.Decode
  • Windows.Data.Json for Win 8+
  • Newtonsoft Json.NET and Json.Linq or Path
  • simple Regex

inherited classes deserialization problem[edit | edit source]

DataContractJsonSerializer cannot deserialize complex objects, and __type is not managed.

XmlSerializer cannot help with complex objects too, only DataContractSerializer is needed.

marking properties[edit | edit source]

As of .NET 3.0, you can use DataContract instead of Serializable. With the DataContract though, you will need to either "opt-in" by marking the serializable fields with the DataMember attribute; or "opt-out" using the IgnoreDataMember... opt-out by default will only serialize public members, while opt-in will only serialize the marked members (regardless of protection level)

opt-in is turned on when class marked by DataContract

Wcf uses Typewriter

Newtonsoft.Json uses JsonProperty, JsonIgnore attributes.

in TypeScript[edit | edit source]