I use the JsonSerializer
from Newtonsoft.
But i want to name the json-objects by myself.
I tried the JsonObject
attribute
[JsonObject(Description = "MyName", Title = "orThisname")]
JsonArray
also didnt work...
Is it possible to name the json-objetcs/arrays by myself?
JsonPropertyAttribute indicates that a property should be serialized when member serialization is set to opt-in. It includes non-public properties in serialization and deserialization. It can be used to customize type name, reference, null, and default value handling for the property value.
Steps to follow the basic patternCreate a class that derives from JsonConverter<T> where T is the type to be serialized and deserialized. Override the Read method to deserialize the incoming JSON and convert it to type T . Use the Utf8JsonReader that's passed to the method to read the JSON.
Deserializes the JSON to the specified . NET type. Deserializes the JSON to the specified . NET type using a collection of JsonConverter.
I think I found the solution:
[JsonProperty(PropertyName = "Myname")]
will rename it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With