Parsing Json in Golang
Concept: []Json array ---->[]Byte array ----> Struct Syntax: func Unmarshal(data []byte, v interface{}) error Code: // Golang program to illustrate the // concept of parsing JSON to an array package main import ( "encoding/json" "fmt" ) // declaring a struct type Competitors struct { // defining struct variables Username string School string Online bool Score int } // main function func main () { // defining a struct instance var competitors []Competitors // JSON array to be decoded // to an array in golang Data := [] byte ( ` [ {"username": "competitor1", "school": "SMK Swasta 1", "online": true, "score": 987}, {"username": "competitor2", "school": "SMK Negeri 7", "online": false, "score": 432}, ...