You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using System.Text.Json.Serialization;
using Newtonsoft.Json;
public class SampleClass
{
[JsonPropertyName("base_currency")] // Does not work (System.Text.Json.Serialization)
[JsonProperty("base_currency")] // Does work (Newtonsoft.Json)
public string BaseCurrency { get; set; }
The text was updated successfully, but these errors were encountered:
The attributes that are honored are based on the serializer in use, which is determined by the formatter you choose. This library comes with two formatters: JsonMessageFormatter (Newtonsoft.Json) and MessagePackFormatter (MessagePack). Neither of these honor System.Text.Json attributes as they are associated with a different serializer. However, both of these formatters (or rather, their underlying serializers) honor the DataContractSerializer attributes (DataContract, DataMember), so maybe the System.Text.Json serializer would honor them too, if you were hoping for one attribute that would work in multiple cases.
As another option, you could write a System.Text.Json-based formatter for this library. We looked into this previously (#305) but didn't see enough demand for it.
The text was updated successfully, but these errors were encountered: