[fpc-devel] TJSONDeStreamer can't handle such date format 'yyyy-MM-dd"T"hh:nn:ss"Z"'
Michael Van Canneyt
michael at freepascal.org
Tue Jul 19 09:54:45 CEST 2016
On Mon, 18 Jul 2016, Stéphane Wierzbicki wrote:
> Hello,
>
> I'm working with the TJSONStreamer and TJSONDeStreamer class. I need to
> exchange JSON object with a REST server. Date needs to be formatted this
> way : 'yyyy-MM-dd"T"hh:nn:ss"Z"'
> Here is what I've done :
>
> Streamer.Options := Streamer.Options + [jsoDateTimeAsString ,
> jsoUseFormatString];
> Streamer.DateTimeFormat := 'yyyy-MM-dd"T"hh:nn:ss"Z"'; //ISO8601
> JSONString := Streamer.ObjectToJSONString(MyObject);
> ....
> DeStreamer.JSONToObject(JSONString , MyObject); <= Exception
>
> I'm getting an exception when converting my string to the object again.
> TJSONDeStreamer failed to convert this format back to
> 'yyyy-MM-dd"T"hh:nn:ss"Z".
>
> I have modified TJSONStreamer and TJSONDeStreamer class to handle ISO8601
> dates by adding a new jsoDateTimeAsISO8601 option.
> Where can I send these modifications ?
What version of FPC did you use ?
The latest version of TJSONStreamer and TJSONDeStreameruse this format
already, check the jsoLegacyDateTime option.
Michael.
More information about the fpc-devel
mailing list