I am trying to parse a JSON of the type
"{\"ids\":[\"a\",\"b\"]}" Here is my code:
package main import "fmt" import "encoding/json" import "strings" type Idlist struct { id []string `json:"ids"` } func main() { var val []byte = []byte(`"{\"ids\":[\"a\",\"b\"]}"`) jsonBody, _ := strconv.Unquote(string(val)) var holder Idlist if err := json.NewDecoder(strings.NewReader(jsonBody)).Decode(&holder); err!= nil{ fmt.Print(err) } fmt.Print(holder) fmt.Print(holder.id) } However, I keep getting output
{[]}[] I cannot get the data in the structure. Where am I going wrong? Here is the playground link: https://play.golang.org/p/82BaUlfrua