Skip to content

Commit 4d6b0d0

Browse files
committed
Merge pull request #9 from relistan/master
Fix time parsing for precision, and float -> issue.
2 parents 48e6706 + a21366c commit 4d6b0d0

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
@@ -16,7 +16,7 @@ function jsonToGo(json, typename)
1616

1717
try
1818
{
19-
data = JSON.parse(json);
19+
data = JSON.parse(json.replace(/\.0/g, ".1"));
2020
scope = data;
2121
}
2222
catch (e)
@@ -119,7 +119,7 @@ function jsonToGo(json, typename)
119119
switch (typeof val)
120120
{
121121
case "string":
122-
if (/\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\+\d\d:\d\d|Z)/.test(val))
122+
if (/\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(\+\d\d:\d\d|Z)/.test(val))
123123
return "time.Time";
124124
else
125125
return "string";

0 commit comments

Comments
 (0)