Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
MadmanDavid
Visitor

ParseJSON inside a Task cannot parse long numbers

I'm trying to parse some timestamps from our server inside a Task and having trouble with long numbers. 

The numbers output from ParseJSON() are "invalid" 

If I use ParseJSON() within the main thread, the Roku has no issue with outputting the correct value.


// Example JSON string
{
    "pin": "8RY2",
    "pinKey": "2589b22c-240d-4a02-8a7f-8ddf2b273b73",
    "expiry": 1484795032530, // This long value (13 numbers) is output as invalid when converting to an AA
    "expired": false
}

// ParseJSON()
{
expired: false
expiry: invalid 'This should be the above value.
pin: "8RY2"
pinKey: "2589b22c-240d-4a02-8a7f-8ddf2b273b73"
}

I'm pretty sure this is not working as intended...

If I shorten the number by 4 digits, it quite happily parses.
0 Kudos
4 REPLIES 4
MadmanDavid
Visitor

Re: ParseJSON inside a Task cannot parse long numbers

On further investigation its not the Task specifically that cannot parse a long value. The passing of the AA back into the scene thread is what causes the issue.
0 Kudos
EnTerr
Roku Guru

Re: ParseJSON inside a Task cannot parse long numbers

"MadmanDavid" wrote:
On further investigation its not the Task specifically that cannot parse a long value. The passing of the AA back into the scene thread is what causes the issue.

Aha! Exactly what i guessed reading your first message.
Yes, because `long` is unsupported by RSG data type. See the list of supported field types, strategically hidden here <interface>-Attributes ? Everything that is not one of them gets stripped during data cloning. `Long` is not one of them, so...
0 Kudos
MadmanDavid
Visitor

Re: ParseJSON inside a Task cannot parse long numbers

Okay. Good to know there's a layer that can posibly mangle attributes. I'll have to keep that in mind.
0 Kudos
EnTerr
Roku Guru

Re: ParseJSON inside a Task cannot parse long numbers

"MadmanDavid" wrote:
Okay. Good to know there's a layer that can posibly mangle attributes. I'll have to keep that in mind.

That will happen every time data has to cross boundaries between threads, be it main and render or task and render - a deep copy is made of it and "unsupported" types are silently(!) lopped off. There are somewhat complicated rules which thread owns what objects, so beware it may not be obvious when
0 Kudos