Skip to content

Commit f5cbf55

Browse files
committed
Fix issue #18: support nested array
1 parent db97bb7 commit f5cbf55

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

json-to-go.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ function jsonToGo(json, typename)
9292

9393
parseStruct(struct, omitempty); // finally parse the struct !!
9494
}
95+
else if (sliceType == "slice") {
96+
parseScope(scope[0])
97+
}
9598
else
9699
append(sliceType || "interface{}");
97100
}
@@ -181,9 +184,9 @@ function jsonToGo(json, typename)
181184
case "boolean":
182185
return "bool";
183186
case "object":
187+
if (Array.isArray(val))
188+
return "slice";
184189
return "struct";
185-
case "array":
186-
return "slice";
187190
default:
188191
return "interface{}";
189192
}

0 commit comments

Comments
 (0)