9 //Thanks https://github.com/chuckpreslar/inflect for the UpperCamelCase
11 // Split's a string so that it can be converted to a different casing.
12 // Splits on underscores, hyphens, spaces and camel casing.
13 func split(str string) []string {
14 // FIXME: This isn't a perfect solution.
15 // ex. WEiRD CaSINg (Support for 13 year old developers)
16 return strings.Split(regexp.MustCompile(`-|_|([a-z])([A-Z])`).ReplaceAllString(strings.Trim(str, `-|_| `), `$1 $2`), ` `)
19 // UpperCamelCase converts a string to it's upper camel case version.
20 func UpperCamelCase(str string) string {
23 for index, s := range pieces {
24 pieces[index] = fmt.Sprintf(`%v%v`, strings.ToUpper(string(s[0])), strings.ToLower(s[1:]))
27 return strings.Join(pieces, ``)
30 func (that *JSONNode) printValue(indentlevel int, indentchar string) {
31 fmt.Printf(" %T ", that.Get())
34 func (that *JSONNode) printMap(indentlevel int, indentchar string) {
35 fmt.Printf(" struct {\n")
36 for key := range that.m {
37 printfindent(indentlevel+1, indentchar, "%s", UpperCamelCase(key))
38 that.m[key].print(indentlevel+1, indentchar)
39 fmt.Printf(" `json:\"%s\"`\n", key)
41 printfindent(indentlevel, indentchar, "}")
44 func (that *JSONNode) printArray(indentlevel int, indentchar string) {
46 fmt.Printf(" []interface{} ")
50 for key := range that.a {
51 that.a[key].print(indentlevel+1, indentchar)
56 //DebugProspect Print all the data the we ve got on a node and all it s children
57 func (that *JSONNode) print(indentlevel int, indentchar string) {
60 that.printValue(indentlevel, indentchar)
62 that.printMap(indentlevel, indentchar)
64 that.printArray(indentlevel, indentchar)
66 printfindent(indentlevel, indentchar, "Is of Type: TypeUndefined\n")
70 //Print Print all the data the we ve got on a node and all it s children as a go struct :) (FOR DEV PURPOSE)
71 func (that *JSONNode) Print() {