I have this list as a string:
["test1","test2"]
How do I convert? From my limited understanding this is an interface:
[]interface{}
if so then how do I convert to an array?
fmt.Println(test)
["test1", "test2"]
fmt.Println(reflect.TypeOf(test))
string
I tried the below:
in := []byte(test)
var raw []interface{}
json.Unmarshal(in, &raw)
fmt.Println(raw[0])
the above worked fyi
Thanks
Your json as a list of string will decode using a golang list of strings
package main
import (
"encoding/json"
"fmt"
)
func main() {
fmt.Println("Hello, playground")
test := `["test1","test2"]`
in := []byte(test)
var raw []string
json.Unmarshal(in, &raw)
fmt.Println(raw[0])
}