Summary
Prop method allows to specify property name when serializing object properties.
Syntax
function Prop(const AName: string): TSerializer;
Parameters
- AName
Type: string
The name of serializing property.
Return Value
Prop method always return the same serializer object. This allows to write S.Prop('MyProp').Value<Integer>(0) in a single line.
Remarks
Prop method calls are only possible while serializing object data manually; that is - after NG.Serialization.TSerializer.BeginObject(string,Boolean) and before corresponding NG.Serialization.TSerializer.EndObject method calls. The process of a property serialization should include two method calls: first, Prop method should be called to begin property and specify its name, and then, one of the methods which provides property value, should be called. The following methods can be called after Prop method to specify a property value:
- Value method.
- NG.Serialization.TSerializer.Null method, if property value is Null.
- NG.Serialization.TSerializer.BeginObject(string,Boolean)/NG.Serialization.TSerializer.EndObject methods, if property value is an object itself.
- NG.Serialization.TSerializer.BeginArray(string)/NG.Serialization.TSerializer.EndArray methods, if property value is an array.
Delphi | Copy Code |
---|---|
S.Prop('MyProp').Value<Integer>(0); |
Examples
Delphi | Copy Code |
---|---|
S.BeginObject('Customer', False); S.Prop('Name').Value<string>('Juana Aguirre'); S.Prop('Address').BeginObject('', False); S.Prop('Counrty').Value<string>('ARGENTINA'); S.Prop('PostalCode').Value<string>('C1070AAM'); S.EndObject; S.EndObject; |