loading...

June 1, 2010

Preserve epoch dates in Zimbra JSON via ColdFusion DeserializeJSON function

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:

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:

jsonData = reReplace(jsonData, ‘([0-9]{10,})’, ‘”1″‘, ‘ALL’)>

Posted in DevelopmentTaggs: