Handling Java time stamps (longs) in a tWriteJSONField

Six Stars

Handling Java time stamps (longs) in a tWriteJSONField

I'm trying to write Java timestamps out to a JSON object using tWriteJSONField, and not getting very far.

 

Not setting the type attribute yields the timestamp in a quoted string (E.g., "1531434936872")

Setting the type attribute to "integer" yields a NumberFormatException

Setting the type attribute to "number" turns the timestamp into a double (E.g., 1.531434846295E12)

Setting the type attribute to "object" yields an empty object ("{}")

 

Is there a way to handle this?

Moderator

Re: Handling Java time stamps (longs) in a tWriteJSONField

Hello,

Could you please elaborate your case with an example with input and expected output values?

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Six Stars

Re: Handling Java time stamps (longs) in a tWriteJSONField

Given this simple job:

 

JsonJob.PNG

Where the row generator queries the current system time like this

randomRowTs.PNG

And the JSON tree in tWriteJSONField is configured like this:

JsonTree.PNG

I get the following output:

Starting job TestJavaTimestamp at 09:18 16/07/2018.

[statistics] connecting to socket on port 3627
[statistics] connected
{"currentTime":1.531757903116E12}
[statistics] disconnected
Job TestJavaTimestamp ended at 09:18 16/07/2018. [exit code=0]

I would expect output like this:

{"currentTime":1531757892465}