String to struct

Run Settings
LanguageGo
Language Version
Run Command
package main import ( "fmt" "encoding/json" ) type res struct{ MessageCount string `json:"message-count"` Messages []messages `json:"messages"` } type messages struct{ RemainingBalance string `json:"remaining-balance"` } func main() { data := `{"message-count":"1","messages":[{"message-id":"d1093f29-d6d2-4446-981f-0f50d28be833","message-price":"0.20980000","network":"51010","remaining-balance":"17.38130000","status":"0","to":"6281231486465"}]}` e := res{} json.Unmarshal([]byte(data), &e) fmt.Println(e.Messages[0].RemainingBalance) }
Editor Settings
Theme
Key bindings
Full width
Lines