Selection of a nested array is not working

[Name]=beatport.com [v5.0 by stevehero™] (◣_◢)
[BasedOn]=https://www.beatport.com
[IndexUrl]=https://www.beatport.com/search/releases?q=%s&per-page=25&sort=release-desc
[AlbumUrl]=
[WordSeparator]=+
[IndexFormat]=% ↓ ID (◣_◢)™%|% ↓ RELEASE%|% ↓ ARTIST/S%|%_URL%
[Encoding]=url-utf-8
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
[ParserScriptIndex]=...
findline "<!DOCTYPE html>"
findinline "<!DOCTYPE html>"
joinuntil "</html>"
replace "|" "$verticalBar()"
regexpreplace "(?i).*?window\.Playables\s*?=\s*?(\{.+);.*?window\.Sliders\s+=\s+\[.*" "$1"
json "ON" "current"
json_foreach "releases"
json_select "id" # ID
sayrest
say "|"
json_select "name" # RELEASES
sayrest
say "|"
json_select_many "artists" "name" " ● " # ARTIST(S)
sayrest
say "|"
say "https://www.beatport.com/release/" # PREVIEW
json_select "slug"
sayrest
json_select "id"
say "/"
sayrest
saynewline
json_foreach_end
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
[ParserScriptAlbum]=...
# START JSON PARSING
gotoline 5
findline "<!DOCTYPE html>"
findinline "<!DOCTYPE html>"
joinuntil "</html>"
replace "|" "$verticalBar()"
regexpreplace "(?i).*?window\.Playables\s*?=\s*?(\{.+);.*?window\.Sliders\s+=\s+\[.*" "$1"
regexpreplace "\"tracks\": ?\[\s*\]\," "" # Remove empty tracks array
json "ON" "current"

json_select_array "releases" 1

# THERE'S A PROBLEM WITH THIS SELECTING AN ARRAY AND RETURNING THE TOTAL TRACK COUNT
outputto "TOTALTRACKS"
json_foreach "tracks"
sayrest
json_foreach_end

json_unselect_object # Deselect releases
json_unselect_object # Deselect tracks

The above outputs 0 to the TOTALTRACKS field when AFAIK should count the length of the arrray.

Perhaps it's something I'm doing here.

Here's a similar issue that was resolved. Perhaps it's something on mp3tags' end @Florian ?

I'm removing empty arrays beforehand with:

regexpreplace "\"tracks\": ?\[\s*\]\," "" # Remove empty tracks array

so all I'm left with is the correct one but so far I've not been able to get this working.

It would be helpful if you could also post steps to reproduce with your questions. I've tried several sample releases as input which all didn't have tracks under releases when running the script.

Sometimes, (all the time) I'm a numbnuts. I took for granted that the track items were under the releases but they are their own array mixed with non-release tracks.

json_foreach "tracks"
json_select "component"
if "Release Track Listing"

outputto "BEATPORT_TRACK_ID"
json_select "id"
sayrest
say "|"

outputto "TRACKS"
sayrest
say "|"

endif
json_foreach_end