[fpc-pascal] JSONRTTI load and save TDateTime issues
Graeme Geldenhuys
mailinglists at geldenhuys.co.uk
Thu Sep 24 13:00:48 CEST 2015
Hi,
I'm using the JSONRTTI unit to successfully save an object to a .json
file. But when loading that file back using TJSONDeStreamer I get a
conversion error due to the Date/Time format.
Here is the code to handle the TDateTime fields of my object - I store
them as ISO8601 date/time format.
js := TJSONStreamer.Create(nil);
try
js.Options := [jsoDateTimeAsString];
js.DateTimeFormat := 'yyyymmdd"T"hhnnss';
j := js.ObjectToJSON(ASettings);
The problem is, the TJSONDeStreamer doesn't have the equivalent Options
property or DateTimeFormat property that TJSONStreamer has, so how is it
supposed to know how to handle Date/Time fields? No wonder it gives a
Conversion Error.
If I comment out my js.DateTimeFormat line above, then saving and
loading works. But I don't want the default DateTime-to-String result.
Any ideas? I'm using FPC 2.6.4.
Regards,
- Graeme -
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/
My public PGP key: http://tinyurl.com/graeme-pgp
More information about the fpc-pascal
mailing list