You are not logged in.
Hello,
I have following record definition with Delphi 12.3 and mORMot2.
TProductForUploadAttribute = packed record
attributeId: Int64;
attributeValueId: Variant;
customAttributeValue: Variant;
end;
TProductForUpload = packed record
attributes: TArray<TProductForUploadAttribute>;
end;
The "customAttributeValue" is required optional like below by the 3rd party web service I am using.
"attributes": [
{
"attributeId": 1,
"attributeValueId": 7165
},
{
"attributeId": 3,
"attributeValueId": null,
"customAttributeValue": "AÇIK TABA SÜET"
}
]
When I serialize the record "customAttributeValue" is included in all array items. Is there a way to automatically exclude it like above? Maybe when it's value is Unassigned?
Thanks & Regards,
Ertan
Offline
Check TTextWriterWriteObjectOption
Permanent
initialization
Rtti.ByTypeInfo[TypeInfo(TProductForUploadAttribute )].Props.NameChange('customAttributeValue', '');
With Custom-Serializer in this example.
With best regards
Thomas
Offline
TTextWriterWriteObjectOption--> [woDontStoreVoid]
Offline