Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
EnTerr
Level 8

Buglet: FormatJSON: Value type not supported: roList

BrightScript Debugger> ? formatJSON( "1,2,3,4".tokenize(",") )
BRIGHTSCRIPT: ERROR: FormatJSON: Value type not supported: roList

BrightScript Debugger> ? formatJSON( createObject("roFileSystem").GetDirectoryListing("pkg:/") )
BRIGHTSCRIPT: ERROR: FormatJSON: Value type not supported: roList

BrightScript Debugger> ? formatJSON( createObject("roRegistry").getSectionList() )
BRIGHTSCRIPT: ERROR: FormatJSON: Value type not supported: roList

Umm... wat? Multiple B/S APIs return roList and not roArray, for whatever h*st*rical reason. formatJSON() should not be picky between roList and roArray.
0 Kudos
2 Replies
belltown
Level 7

Re: Buglet: FormatJSON: Value type not supported: roList

I agree that FormatJson should handle roLists the same as it does roArrays. However, I wouldn't call it a "buglet", since it states in the BrightScript Reference that "Data types supported are booleans, integer and floating point numbers, strings, roArray, and roAssociativeArray objects"; there's no mention of roList. However, the documentation is rather misleading as the first sentence states: "Formats an Associative Array as a JSON string". Yes, that's true, but it also formats arrays and primitive objects, not just associative arrays.
https://github.com/belltown/
0 Kudos
EnTerr
Level 8

Re: Buglet: FormatJSON: Value type not supported: roList

Other than me and you @belltown, there probably are somewhere between 3 and 5 other people outside RokuCo that know and care about the difference between "roArray" and "roList". And i still don't know the reason to differentiate between these two - if Lua can make-do with only 1 type ("table") for both lists/arrays and hash-dictionaries - why can't B/S settle on only [ ]  and { }? Perhaps for h*st*rical reasons but a good number of APIs return roList instead of roArray.

So from a pragmatic point of view, un-handling of roList is a shortfall of formatJSON - even if by documents it could not be "convicted" of a bug. roList looks like a duck, quacks like a duck... it should formatJSON as a duck.

Regarding the partial documentation as "Formats an Associative Array as a JSON string" - that's a leftover from two years ago when formatJSON() was accepting only { } at top level and was crashing the player with cyclic structures, cue viewtopic.php?f=34&t=66765#p429036
0 Kudos