Skip to content

Commit 4c0cf8a

Browse files
committed
⬆️ Update json-to-go
refs: mholt/json-to-go#120
1 parent 2af03f3 commit 4c0cf8a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

vendor/json-to-go.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function jsonToGo(json, typename, flatten = true, example = false, allOmitempty
2222

2323
try
2424
{
25-
data = JSON.parse(json.replace(/:(\s*\d*)\.0/g, ":$1.1")); // hack that forces floats to stay as floats
25+
data = JSON.parse(json.replace(/(:\s*\[?\s*-?\d*)\.0/g, "$1.1")); // hack that forces floats to stay as floats
2626
scope = data;
2727
}
2828
catch (e)
@@ -62,7 +62,7 @@ function jsonToGo(json, typename, flatten = true, example = false, allOmitempty
6262
else if (sliceType != thisType)
6363
{
6464
sliceType = mostSpecificPossibleGoType(thisType, sliceType);
65-
if (sliceType == "interface{}")
65+
if (sliceType == "any")
6666
break;
6767
}
6868
}
@@ -130,9 +130,9 @@ function jsonToGo(json, typename, flatten = true, example = false, allOmitempty
130130
}
131131
else {
132132
if (flatten && depth >= 2) {
133-
appender(sliceType || "interface{}");
133+
appender(sliceType || "any");
134134
} else {
135-
append(sliceType || "interface{}");
135+
append(sliceType || "any");
136136
}
137137
}
138138
}
@@ -316,7 +316,7 @@ function jsonToGo(json, typename, flatten = true, example = false, allOmitempty
316316
function goType(val)
317317
{
318318
if (val === null)
319-
return "interface{}";
319+
return "any";
320320

321321
switch (typeof val)
322322
{
@@ -342,7 +342,7 @@ function jsonToGo(json, typename, flatten = true, example = false, allOmitempty
342342
return "slice";
343343
return "struct";
344344
default:
345-
return "interface{}";
345+
return "any";
346346
}
347347
}
348348

@@ -356,7 +356,7 @@ function jsonToGo(json, typename, flatten = true, example = false, allOmitempty
356356
&& typ2.substr(0, 5) == "float")
357357
return typ2;
358358
else
359-
return "interface{}";
359+
return "any";
360360
}
361361

362362
// Proper cases a string according to Go conventions

0 commit comments

Comments
 (0)