Skip to content

Instantly share code, notes, and snippets.

@nicholasf
Created August 11, 2014 02:03
Show Gist options
  • Save nicholasf/ce6f117d10557007184e to your computer and use it in GitHub Desktop.
Save nicholasf/ce6f117d10557007184e to your computer and use it in GitHub Desktop.
// func recurse(jsonMap map[string]interface{}, parent *TreeNode) {
// data := jsonMap
// child := TreeNode{ nil, parent, data }
// for k, v := range jsonMap {
// switch vv := v.(type) {
// case string:
// fmt.Println(k, "is string")
// case int:
// fmt.Println(k, "is int")
// case float64:
// fmt.Println(k, "is a float64")
// case []interface{}:
// fmt.Println(k, "is an array")
// for _, u := range vv {
// switch item := u.(type) {
// case []interface{}:
// recurse(u.(map[string]interface{}), nil)
// case string:
// fmt.Println(item)
// case bool:
// fmt.Println(item)
// case interface{}:
// recurse(u.(map[string]interface{}), nil)
// default:
// fmt.Println(k, "(inside array) is of a type I don't know how to handle")
// }
// }
// case bool:
// fmt.Println(k, "is a bool")
// case interface{}:
// fmt.Println(k, "recursing ....")
// m := v.(map[string]interface{})
// recurse(m, &child)
// default:
// fmt.Println(k, "is of a type I don't know how to handle")
// }
// }
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment