I want to get a string that represents a json like this one:
{ "votes": { "option_A": "3" } }
and inclu
package main
import "encoding/json"
func main() {
in := []byte(`{ "votes": { "option_A": "3" } }`)
var raw map[string]interface{}
if err := json.Unmarshal(in, &raw); err != nil {
panic(err)
}
raw["count"] = 1
out, err := json.Marshal(raw)
if err != nil {
panic(err)
}
println(string(out))
}
https://play.golang.org/p/o8ZwvgsQmoO