This commit is contained in:
Alexander Pivkin
2025-09-05 18:02:53 +03:00
parent 45d9a8ea83
commit 0309c74925
4 changed files with 90 additions and 18 deletions
+3
View File
@@ -0,0 +1,3 @@
module main
go 1.24.6
+25
View File
@@ -0,0 +1,25 @@
package main
import (
"encoding/json"
"fmt"
"log"
)
func main() {
input := `{
"name": "John Doe",
"age": 15,
"hobbies": ["climbing", "cycling", "running"]
}`
var target map[string]any
err := json.Unmarshal([]byte(input), &target)
if err != nil {
log.Fatalf("Unable to marshal JSON due to %s", err)
}
for k, v := range target {
fmt.Printf("k: %s, v: %v\n", k, v)
}
}