Forum Discussion

360tv's avatar
360tv
Streaming Star
10 years ago

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.

2 Replies

  • renojim's avatar
    renojim
    Community Streaming Expert
    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
  • 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