diff --git a/json-to-struct.go b/json-to-struct.go index 811ee71..9f41d43 100644 --- a/json-to-struct.go +++ b/json-to-struct.go @@ -297,7 +297,8 @@ func generateTypes(obj map[string]interface{}, structName string, tags []string, if val, ok := subStructMap[sub]; ok { subName = val } else { - subName = fmt.Sprintf("%v_sub%v", structName, len(subStructMap)+1) + //subName = fmt.Sprintf("%v_sub%v", structName, len(subStructMap)+1) + subName = structName + strings.Title(key) subStructMap[sub] = subName } @@ -314,7 +315,8 @@ func generateTypes(obj map[string]interface{}, structName string, tags []string, if val, ok := subStructMap[sub]; ok { subName = val } else { - subName = fmt.Sprintf("%v_sub%v", structName, len(subStructMap)+1) + //subName = fmt.Sprintf("%v_sub%v", structName, len(subStructMap)+1) + subName = structName + strings.Title(key) subStructMap[sub] = subName } @@ -328,7 +330,8 @@ func generateTypes(obj map[string]interface{}, structName string, tags []string, if val, ok := subStructMap[sub]; ok { subName = val } else { - subName = fmt.Sprintf("%v_sub%v", structName, len(subStructMap)+1) + //subName = fmt.Sprintf("%v_sub%v", structName, len(subStructMap)+1) + subName = structName + strings.Title(key) subStructMap[sub] = subName }