Skip to content

Commit 6b0191c

Browse files
committed
Handling hyphens in field names
1 parent cfde906 commit 6b0191c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

json-to-go.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ function jsonToGo(json, typename)
104104
'8': "Eight_", '9': "Nine_"};
105105
str = numbers[str.charAt(0)] + str.substr(1);
106106
}
107-
return toProperCase(str).replace(/\s|_/g, "");
107+
return toProperCase(str).replace(/\s|_|-/g, "");
108108
}
109109

110110
function goType(val)
@@ -159,7 +159,7 @@ function jsonToGo(json, typename)
159159

160160
str = str.charAt(0).toUpperCase() + str.substr(1);
161161

162-
return str.replace(/[\s_][a-z]+/g, function(txt)
162+
return str.replace(/[\s_-][a-z]+/g, function(txt)
163163
{
164164
return txt.charAt(0)
165165
+ txt.charAt(1).toUpperCase()

0 commit comments

Comments
 (0)