yo so i need a bit of help. so i need to get the value of time and player under each category.
the command would be !wr sm64 120_star. then the script would go to http://www.speedrun.com/api_records.php?game=sm64
then it would parse and find the values for player and time under the category 120 star. but because the game constantly changes i need to be able to read the first value and basely skip over it. but i want the end response to be "the world record for Super Mario 64 is (time) by (player)" but speedrun.com allows for abbreviations such as sm64, but i want the response to have the whole name. and the json does contain the whole name. so in the end i need to get the first value then parse to the time and player and output all 3.
here is my code so far.
on *:TEXT:!wr *:#: {
if (!%comwr) {
set -u1 %comwr 1
JSONOpen -u wr http://www.speedrun.com/api_records.php?game= $+ $replace($2 , _, $chr(32))
msg $chan http://www.speedrun.com/api_records.php?game= $+ $replace($2 , _, $chr(32))
msg $chan test $json(wr, (help needed), $replace($3 , _, $chr(32)))
JSONClose wr
else {
msg $chan Sorry $nick $+ , no one is playing $2-
JSONClose stream
}
}
else {
msg $chan Sorry $nick this command is on cooldown.
}
}
Mkay, that API is not following generally accepted 'best' JSON practices: its using non-static data for item keys; due to this, my JSON parser may not correctly be able to handle this data.
With that said, you may be able to use
$JSON().fuzzy
to access the child members assuming that the child members to be accessed have non totally numeric keys: