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: 
pcnweb
Channel Surfer

Debugger - Print Associative Array?

Is it possible to "print" or enumerate an associative array in the debugger? If yes, how so?
0 Kudos
6 REPLIES 6
RokuMarkn
Visitor

Re: Debugger - Print Associative Array?

roAssociativeArray supports the ifEnum interface, so you can just say

for each key in aa ...

Several of the examples have a PrintAA function that will print an AssociativeArray using this technique.

--Mark
0 Kudos
EnTerr
Roku Guru

Re: Debugger - Print Associative Array?

"print" comes to mind :). Seriously though, the print output has improved recently (7.1). Cue:
BrightScript Debugger> ? config
<Component: roAssociativeArray> =
{
init1: 5
init2: 1332175218
name: Kuro%.2s%s
origin: http://localhost
servers: <Component: roArray>
}

When i want to see the nested data, i'd use "? formatJSON(...)"
0 Kudos
squirreltown
Roku Guru

Re: Debugger - Print Associative Array?

"EnTerr" wrote:
"print" comes to mind :). Seriously though, the print output has improved recently (7.1).


I noticed that. I was like "why is it printing that array?

"EnTerr" wrote:
When i want to see the nested data, i'd use "? formatJSON(...)"


Great idea. Thanks
Kinetics Screensavers
0 Kudos
pcnweb
Channel Surfer

Re: Debugger - Print Associative Array?

Secondary question: How do I print an associative array in this scenario?

<Component: roArray> =
[
<Component: roAssociativeArray>
]
0 Kudos
pcnweb
Channel Surfer

Re: Debugger - Print Associative Array?

I should pay more attention the answers:

? formatJSON(myVariable)

Does the job, thanks all!
0 Kudos
EnTerr
Roku Guru

Re: Debugger - Print Associative Array?

"pcnweb" wrote:
Secondary question: How do I print an associative array in this scenario?
<Component: roArray> =
[
<Component: roAssociativeArray>
]

Yep, serializing to JSON will do it if bearable enough to watch. Or looking at the above, you got yourself an "array of dictionaries" [{}], so to see what's inside, have to peel the top level first, e.g. "? myVar[0]" will print you the top level of the AA. I know, can be confusing - but at least now PRINT mentions the type and shows the [ ] or { } brackets, before if i remember it would just dump the content. BEFORE it was something like:
BrightScript Debugger> ? [ { } ]
<Component: roAssociativeArray>

0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.