-
Notifications
You must be signed in to change notification settings - Fork 0
JsonNameAttribute
Name attribute. Attach to an member of a class to indicate an alternate name to use in the JSON structure from its c# name.
Applicable to FromObject and ToObject.
ToObject supports multiple names (any name in JSON will match this entry), FromObject only one and uses the first entry if multiple is given
public sealed class JsonNameAttribute : System.AttributeInheritance System.Object 🡒 System.Attribute 🡒 JsonNameAttribute
Constructor with name list, applies to all sets.
ToObject, this names a list of names to accept
FromObject, the first name in the list is used for the output
public JsonNameAttribute(params string[] names);
names System.String[]
Constructor with set name and name list. Bool is just used as a marker. Set names can be repeated.
sets and names must be the same length
public JsonNameAttribute(string[] sets, string[] names);
sets System.String[]
names System.String[]
List of names for this attribute
public string[] Names { get; set; }If non null, this lists the names of the sets associated with the name list.
Must be the same length as Names list
For ToObject, sets can be mentioned more than once to get multiple names accepted.
For FromObject, the first matching set name gives the name of the output JSON variable
Attribute sets allow selection of different inputs and outputs from the same class
public string[] Sets { get; set; }