So I'm trying to access a hash table in Racket, but I can not figure out why it's not working.
When I call hash->list
on this hash:
{"26220765": [
{
"queue": "RANKED_SOLO_5x5",
"name": "Viktor's Marauders",
"participantId": "26220765",
"entries": [
{
"leaguePoints": 0,
"isFreshBlood": false,
"isHotStreak": false,
"division": "IV",
"isInactive": false,
"isVeteran": true,
"losses": 168,
"playerOrTeamName": "iGT500",
"playerOrTeamId": "32156611",
"wins": 173
},
{
"leaguePoints": 0,
"isFreshBlood": true,
"isHotStreak": false,
"division": "V",
"isInactive": false,
"isVeteran": false,
"losses": 255,
"playerOrTeamName": "dragdan",
"playerOrTeamId": "20430418",
"wins": 265
},
It returns
((|26220765| #hasheq((name . "Viktor's Marauders") (queue . "RANKED_SOLO_5x5") (tier . "PLATINUM") (entries . (#hasheq((playerOrTeamId . "32156611") (division . "IV") (playerOrTeamName . "iGT500") (leaguePoints . 0) (wins . 173) (losses . 168) (isHotStreak . #f) (isVeteran . #t) (isFreshBlood . #f) (isInactive . #f)) #hasheq((playerOrTeamId . "20430418") (division . "V") (playerOrTeamName . "dragdan") (leaguePoints . 0) (wins . 265) (losses . 255) (isHotStreak . #f) (isVeteran . #f)
I can not access the hash by using the key 26220765. I've tried defining it as summoner-id
and passing it, i've tried using '26220765
, it doesn't work. I don't understand why it's being displayed with vertical bars, and if I try '|26220765|
or |26220765|
it doesn't work either.
I had another hash table where I needed to access the hash "champions"
, and using 'champions
worked, so why isn't this working?
'|26220765|
should work. It's being displayed with vertical bars because it's a symbol, but it's only composed of numeric characters, so it needs to be escaped. – Alexis Kingsummoner-id
? basically I need'|summoner-id|
, but I think I need to escapesummoner-id
so what's between the '| | is a number, but that number changes depending on who I look up with the API. Any ideas? – suhmedohsummoner-id
a string or a number? – Alexis King(define summ-key (if (not (hash? league-hash-json)) (printf "No ranked data to judge.\n") (hash-keys league-hash-json)))
because at this particular point, it's always returning a hash with the id as the key, and another hash as teh value, and i found that hash-keys lists all the keys in a hash, but only the outtermost layer, if you get what I mean? so this will always be a list with the correct id, so I just take the car of the list and I know it will always match(if they exist). thanks for your help though! – suhmedoh(string->symbol (number->string summoner-id))
. – Alexis King