#1 2019-03-26 09:07:17

Goulu
Member
From: Switzerland
Registered: 2018-09-18
Posts: 6
Website

How to handle TTextWriterWriteObjectOptions in a custom serializer ?

I have custom class serializers that calls aJSONSerializer.AddJSONEscape(['pairof',Fields]),
but I notice the Fields aren't written using the options I passed to the calling ObjectToJSON(myObject, myTextWriterWriteObjectOptions)
because in

procedure TTextWriter.AddJSONEscape(const V: TVarRec);
begin
  with V do
  case VType of
    (* other cases *)
    vtObject:   WriteObject(VObject); // has no Options
  end;
end;

Did I miss something ?

Last edited by Goulu (2019-03-26 13:02:06)

Offline

#2 2019-03-26 14:23:21

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: How to handle TTextWriterWriteObjectOptions in a custom serializer ?

Call instead

procedure TTextWriter.Add(const V: TVarRec; Escape: TTextWriterKind;
  WriteObjectOptions: TTextWriterWriteObjectOptions)

Offline

#3 2019-03-26 15:51:15

Goulu
Member
From: Switzerland
Registered: 2018-09-18
Posts: 6
Website

Re: How to handle TTextWriterWriteObjectOptions in a custom serializer ?

Perfect ! Thanks !

Offline

Board footer

Powered by FluxBB