-
Notifications
You must be signed in to change notification settings - Fork 85
NeonProperty
The NeonProperty
attribute is used to map property names with JSON keys during serialization and deserialization. By default, if you try to serialize a Delphi structure, the generated JSON will have keys mapped to the fields of the structure. The NeonProperty
attribute takes a string that specifies the name that should be mapped to the field during.
This is useful when you have to map some JSON field with a certain key that is a keyword in the programming language that you use, for example if you have to produce this JSON string from a Delphi structure:
{
"Type": "init",
"Name": "Initialization Command",
"Value": [2,3,67,64,88,3,2]
}
Of course you can’t name a variable Type
in Delphi, so In order to do that you can choose a different name and then use the NeonProperty
attribute:
TCommand = record
[NeonProperty('Type')]
CommandType: string;
Name: string;
Value: TArray<Byte>;
end;
Neon Libray • Project Home • paolo's Repositories