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: 
360tv
Level 7

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
renojim
Level 10

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
0 Kudos
Komag
Level 9

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