[8.1.25] Authentication Challenge payload changes java.util.date into unicode

When passing a java.util.date type object through an authentication challenge payload, the object is changed into a unicode object before being handed off to the authentication challenge complete handler.

To test this I made a button on my main view with the following script:

	logger = system.util.getLogger("ButtonScript")
	payload = {
		"identifier": "DateTest",
		"date": system.date.now()
	system.perspective.authenticationChallenge(payload=payload, framing="embedded")

My authentication challenge complete handler has the following code:

logger = system.util.getLogger("AuthChallenge")
sourceType = payload.get("identifier", None)
if sourceType == "DateTest":

Looking at my logs, the 'date' member starts as a java.util.date object, but once received in the challenge complete handler, the 'date' member is now a unicode object.


JSON doesn't know anything about dates.

There's a good flowchart of JSON construction here:


As mentioned in the docs, the payload must be JSON-encodable. JSON doesn't have a 'real' date type - only strings, numbers, booleans, and null. So if you want a lossless datetime you can "rehydrate" into a real Date object on the other side, send your payload as system.date.now().time (or system.date.toMillis(system.date.now()) and then use system.date.fromMillis on the other side.


Was not aware of this, I've only ever passed strings/ints through payloads.

For some reason I thought that Ignition did a smart conversion when handling the payload. Don't know why. :upside_down_face:

Guess this means I need to make a method to crawl my payload and convert all the dates to long ints

I'd go with Paul's toMillis suggestion. The conversion back to datetime is simple and foolproof. Avoid working with dates as strings other than to convert them at the last possible moment for human consumption.


I always use the base date objects, in this case I was running into the problem of unknowingly passing a query a string instead of a date. I rely on the components to do the stringify.