Skip to content

Instantly share code, notes, and snippets.

@alashstein
Last active July 14, 2021 05:20
Show Gist options
  • Save alashstein/8f9e72a15c5d1c61326f80a1d1ab0e60 to your computer and use it in GitHub Desktop.
Save alashstein/8f9e72a15c5d1c61326f80a1d1ab0e60 to your computer and use it in GitHub Desktop.
Run this code on playground: https://play.golang.org/p/w_SoK-WMgVJ
package main
import (
"fmt"
"encoding/json"
)
var b = []byte(`{
"Module": [
{
"Containers": "HomeMainFeature2",
"Components" : "MainFeature2",
"Molecules": [
"Gojek_service"
]
}
]
}`)
func main() {
var mappedJson map[string]interface{}
json.Unmarshal([]byte(b), &mappedJson)
module := mappedJson["Module"].([]interface{})
for i := range module {
container := module[i].(map[string]interface{})["Containers"].(string)
fmt.Println(container)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment