[Lazarus] JSON and Object Pascal DateTime

silvioprog silvioprog at gmail.com
Mon Jan 30 16:29:51 CET 2012


Hello,

What the best way to save a datetime value in a JSON object?

1 - JSONObj['datetime'].AsString := DateTimeToStr(Now); // No no no ... :/

2 - JSONObj['datetime'].AsString := DateTimeToJS(Now); // Result:
\/Date(1240718400000)\/, So: { "datetime": "\/Date(1240718400000)\/" }
// Hm... :|

1 or 2, or other?

Is there a native function to convert it? From JSON to DateTime and
from DateTime to JSON?

Thanks,

-- 
Silvio Clécio
====================================
Site - <silvioprog.com.br>
LazSolutions - <code.google.com/p/lazsolutions>
====================================




More information about the Lazarus mailing list