Reputation: 331
If I have json like this:
{"phonenumber": "3456789", emoji: {"emoji1": "12", "emoji2": "23", ...}
This is two level JSON, where the key value inside emoji will be generated dynamically, it means the key name is not fixed, and the number of key value pair will changed accordingly. So what is the syntax to marshal this JSON into a Go struct?
Upvotes: 0
Views: 1285
Reputation: 6425
Use a map:
type Data struct {
PhoneNumber string `json:"phonenumber"`
Emoji map[string]string `json:"emoji"`
}
Upvotes: 2