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: 
360tv
Streaming Star

Can't access these array values.

I'm parsing a json into an array.
is it because of the dashes?

BrightScript Debugger> ? list
count: 15
status: 200
message: Request Successful.
total-series: 1440
results: <Component: roArray>
start: 0


BrightScript Debugger> ? list.total-series
Use of uninitialized variable. (runtime error &he9) in $LIVECOMPILE(28)

BrightScript Debugger> ? list.count
15

BrightScript Debugger> ? list.status
200

BrightScript Debugger> ? list.total-series
Use of uninitialized variable. (runtime error &he9) in $LIVECOMPILE(31)


also here


BrightScript Debugger> ? list.results[0]
noteReason:
reviews-average-stars: 5
fullSeriesName: .hack//Beyond The World
hd: 0
prequelto: 0
romaji: .hack//Sekai no Mukou ni
rating: 15+
user-reviewed: -1
total-reviews: 1
synonym: .hack//The Movie セカイの向こうに
category: , 1 , 15 , 74 , 6 , 161 , 106 , 16 , 5 ,
id: 1036
moviesonly: 1
Movies: 1
stillRelease: 0
watchlist: 0
sequelto: 0
kanji: ドット ハック セカイの向こうに


BrightScript Debugger> ? list.results[0].user-reviewed
Use of uninitialized variable. (runtime error &he9) in $LIVECOMPILE(38)

BrightScript Debugger> ? list.results[0].movies
1

BrightScript Debugger> ? list.results[0].user-reviewed
Use of uninitialized variable. (runtime error &he9) in $LIVECOMPILE(40)

BrightScript Debugger> ? list.results[0].image-320x280
Type Mismatch. (runtime error &h18) in $LIVECOMPILE(41)

BrightScript Debugger> ? list.results[0].reviews-average-stars
Use of uninitialized variable. (runtime error &he9) in $LIVECOMPILE(42)

BrightScript Debugger> ? list.results[0].hd
0


I'm assuming there are format issues with the array keys but I've never encountered this before.
0 Kudos
2 REPLIES 2
renojim
Community Streaming Expert

Re: Can't access these array values.

Try list["total-series"] or list.Lookup("total-series"). That hyphen is getting interpreted as a subtraction operator, i.e., list.total - series. Neither list.total or series actually exist.

-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
Komag
Roku Guru

Re: Can't access these array values.

It would be the same behavior if you had spaces in the key names, such as "total series". If you want to keep using the dot format, ie list.total-series, you could use underscore _ such as list.total_series
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.