Status/Resolution/Reason: Needs Review//
Reporter/Name(from Bugbase): Aaron Neff / ()
Created: 05/11/2018
Components: Language, Serialization
Versions: 2018
Failure Type: Others
Found In Build/Fixed In Build: /
Priority/Frequency: Normal /
Locale/System: / Platforms All
Vote Count: 0
Issue: Currently JSON serialization+deserialization converts DateTime to String without UTC offset
Steps to Reproduce:
1) Run:
<cfscript>
myDateTime = createDate(2018,1,1)
myDateTimeJSON = serializeJSON(myDateTime)
writeOutput(myDateTime.dateTimeFormat("iso") & '<br>' & myDateTimeJSON)
</cfscript>
Actual Result (depending on time zone):
2018-01-01T00:00:00-05:00
"January, 01 2018 00:00:00"
Expected Result (depending on time zone):
2018-01-01T00:00:00-05:00
2018-01-01T00:00:00-05:00
See? JSON serialization causes data loss by dropping the UTC offset.
2) Run:
<cfscript>
myDateTime = createDate(2018,1,1)
myVar = {myDateTime=myDateTime, myQuery=queryNew("myDateTime", "timestamp", [[myDateTime]])}
afterJSON = deserializeJSON(serializeJSON(myVar), false)
writeOutput(myVar.myDateTime.getClass().getName() & '<br>' & myVar.myQuery.myDateTime[1].getClass().getName() & '<br>' & afterJSON.myDateTime.getClass().getName() & '<br>' & afterJSON.myQuery.myDateTime[1].getClass().getName())
</cfscript>
Actual Result:
coldfusion.runtime.OleDateTime
java.sql.Timestamp
java.lang.String
java.lang.String
Expected Result:
coldfusion.runtime.OleDateTime
java.sql.Timestamp
coldfusion.runtime.OleDateTime
java.sql.Timestamp
See? JSON serialization+deserialization converts DateTime to String
Suggestion: THIS.serialization.preserveDateTime to provide correct behavior for #1 and #2
Attachments:
Comments: