I have a problem with parsing empty JSON string into a struct in Golang. In the playground, when I run this code, the marshal function returns unexpected end of JSON input
. But is this the official return of Golang when we parsing an empty JSON string into a struct?
package main
import (
"encoding/json"
"fmt"
)
var respBytes = []byte{}
type ResultStruct struct {
result []map[string]string
}
func main() {
var jsonData ResultStruct
err := json.Unmarshal(respBytes, &jsonData)
fmt.Println(err)
}