How to Unmarshal JSON into a map[string]interface{} in Go

Decode JSON bytes into a flexible map[string]interface{} using json.Unmarshal.

Use encoding/json.Unmarshal to decode JSON bytes into a map[string]interface{}.

import "encoding/json"

var data map[string]interface{}
err := json.Unmarshal(jsonBytes, &data)
if err != nil {
    // handle error
}

The jsonBytes variable must be of type []byte. The &data pointer allows Unmarshal to populate the map with the parsed JSON structure.