package rep import ( "encoding/json" "fmt" ) func ParseJson(inp string) coderep { var raw interface{} err := json.Unmarshal([]byte(inp), &raw) if err != nil { fmt.Println(err) return nil } rep := prepare(raw) return rep } func prepare(raw interface{}) coderep { switch ri := raw.(type) { case []interface{}: return makeCode(ri) case map[string]interface{}: return makeModule(ri) } return nil }