[fpc-pascal] JSONRTTI load and save TDateTime issues
Michael Van Canneyt
michael at freepascal.org
Thu Sep 24 14:06:22 CEST 2015
On Thu, 24 Sep 2015, Graeme Geldenhuys wrote:
> 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.
That's a bug (missing jsoDateTimeAsString in destreamer),
please report it in the bugtracker.
Michael.
More information about the fpc-pascal
mailing list