JsonNameAttribute - robbyxp1/QuickJSON GitHub Wiki

QuickJSON

QuickJSON


JsonNameAttribute Class

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.Attribute

Inheritance System.Object 🡒 System.Attribute 🡒 JsonNameAttribute


Constructors


JsonNameAttribute.JsonNameAttribute(string[]) Constructor

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);
Parameters

names System.String(https://docs.microsoft.com/en-us/dotnet/api/System.Array 'System.Array')


JsonNameAttribute.JsonNameAttribute(string[], string[]) Constructor

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);
Parameters

sets System.String(https://docs.microsoft.com/en-us/dotnet/api/System.Array 'System.Array')

names System.String(https://docs.microsoft.com/en-us/dotnet/api/System.Array 'System.Array')


Properties


JsonNameAttribute.Names Property

List of names for this attribute

public string[] Names { get; set; }
Property Value

System.String(https://docs.microsoft.com/en-us/dotnet/api/System.Array 'System.Array')


JsonNameAttribute.Sets Property

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; }
Property Value

System.String(https://docs.microsoft.com/en-us/dotnet/api/System.Array 'System.Array')