func main() {
resp, err := http.Get("https://api.wynncraft.com/public_api.php?action=statsLeaderboard&type=player&timeframe=alltime")
if err != nil {
panic(err)
}
body, err := io.ReadAll(resp.Body)
resp.Body.Close()
if err != nil {
panic(err)
}
fmt.Printf("%s", body["Player"])
}```
#How could I get the Player of a body?
34 messages ยท Page 1 of 1 (latest)
"request":{"timestamp":1663767548,"version":1.3},"data":[{"name":"Maarcus1","uuid":"b7454a9d-ea64-4dea-a4ef-c544d6861b7c","kills":1462,"level":1484,"xp":107068194358,"minPlayed":241932,"tag":"HERO","rank":"Player","displayTag":false,"veteran":false,
This is what I get, and i'm trying to get the name's value of it
You need to unmarshall the JSON
Unmarshall?? What does that do
There are literally thousands of Golang JSON tutorials out there.
(I picked that one completely at random)
There are also a bunch of very handy tools to help you make the structs from an example JSON string.
Again, at random: https://transform.tools/json-to-go
ty
It's completely frozen after I pasted my stuff there lol
Is there no easier way to do it?
Easier way to unmarshall JSON?
To skip unmarshalling
If you don't unmarshall it, it's just a long string.
I guess I'm just not gonna use Go
Okay. You'll have to unmarshall it in any language, though.
Well, I guess you can just assert it as an object in JavaScript, but that has a lot of it's very own pitfalls.
Not in python
Okay.
You're not "dumb" for not understanding something immediately upon coming across it for the first time.
You're just new, and that's okay.
It's not hard, it's just a little complicated, especially if your background is entirely weakly typed.
Stick with it for a while, and I assure you it'll be worth it.
I'll try
https://go.dev/blog/json is a good read, too, but a bit more abstract.
Don't get me wrong, it has concrete examples in it, it just also covers some of the theory.
...if that even makes sense. I should have a nap.