Skip to content

Commit 39f55ce

Browse files
jheimbachmholt
authored andcommitted
Names that contain '.0' are preserved (#72)
* replace .0 with .1 only in values * replace .0 with .1 only in float values
1 parent 0fce086 commit 39f55ce

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

json-to-go.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function jsonToGo(json, typename, flatten = true)
2222

2323
try
2424
{
25-
data = JSON.parse(json.replace(/\.0/g, ".1")); // hack that forces floats to stay as floats
25+
data = JSON.parse(json.replace(/:(\s*\d*)\.0/g, ":$1.1")); // hack that forces floats to stay as floats
2626
scope = data;
2727
}
2828
catch (e)

0 commit comments

Comments
 (0)