Preserve epoch dates in Zimbra JSON via ColdFusion DeserializeJSON function

Posted by Quinn Madson | Posted in | Posted on 2:14 PM

0

The DeserializeJSON() function in ColdFusion converts an epoch date/time in JSON from something like: 1281364965000 to: 1.281364965E+012.


To prevent this from happening, you can use something like this:

<cfset jsonData = reReplace(jsonData, '([0-9]{13})', '"\1"', 'ALL')>


Alternatively, to convert any number, 10 digits or more into a string to preserve the proper formatting, use something like this:

<cfset jsonData = reReplace(jsonData, '([0-9]{10,})', '"\1"', 'ALL')>

Comments (0)