I have simple program in GO to parse JSON:
package main
import (
"encoding/json"
"fmt"
)
func main() {
jsonData := `{"aaa": {"bbb": {"ccc": [{"file_1": "file.jpg", "file_2": "file.png"}]}}}`
var result map[string]map[string]map[string]interface{}
json.Unmarshal([]byte(jsonData), &result)
files := result["aaa"]["bbb"]["ccc"].(map[string]interface{})
for key, value := range files {
fmt.Println(key, value)
}
}
https://go.dev/play/p/dxv8k4pI7uX
I would like to receive list of files, so response should be:
file_1 file.jpg file_2 file.png
but this code return me error:
panic: interface conversion: interface {} is []interface {}, not map[string]interface {}
What I'm doing wrong?