I want to create a map that I can transform into a json object such as
{
"a": "apple",
"b": 2
}
but golang specifies that the map be declare with types, so I can have map[string]string or map[string]int. How do I create a json object like the above?
Note: I won't know what data and/or types I need until runtime or when I need to create the json object. Therefore I can't just create an object like
type Foo struct {
A string `json:"a"`
B int `json:"b"`
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…