Timestamp delta during conversion

I have a response from server which should look like below.

{ “startDate”: 1695034800, “endDate”: 1695036540 }

However, the response is print as below in the console.

{“startDate”:1.6950348e+09,“endDate”:1.69503654e+09}

I convert the printed startDate to a variable as below.

timestamp& = json.startDate

Here, I get incorrect value 1695034752, when it should have been 1695034800. How do I get the correct value?

I think you need to figure out why the server is returning a floating point number.

Server is sending long int values as below. I see this in the postman.
{ “startDate”: 1695034800, “endDate”: 1695036540 }

It works for me:

x="{ "+chr(34)+"startDate"+chr(34)+": 1695034800, "+chr(34)+"endDate"+chr(34)+": 1695036540 }"
?x
{ "startDate": 1695034800, "endDate": 1695036540 }
?parsejson(x)
<Component: roAssociativeArray> =
{
    endDate: 1695036540
    startDate: 1695034800
}
?parsejson(x).enddate
 1695036540
?parsejson(x).startdate
 1695034800
?parsejson(x).enddate - parsejson(x).startdate
 1740
json=parsejson(x)
startdate&=json.startdate
enddate&=json.enddate
?startdate&
 1695034800
?enddate&
 1695036540
?enddate&-startdate&
 1740

The numbers are just Integers, so no need really for the LongIntegers, but it doesn’t affect anything.

I don’t understand where the floating point numbers are entering the situation. Maybe post your code.

Thank you for trying.

The floating point are entering from the roUrlTransfer. When I get the string from the msg object of the listening port, it is printed as floating point. Additionally when I just copy the floating point into epoch converter, I get the correct value. It’s Roku which is not able to parse it.