File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ function main()
99 [" str" ] = json .array (" hello" ),
1010 [" int" ] = json .array (12 ),
1111 [" bool" ] = json .array (true ),
12- [" float" ] = json .array (12.34 )
12+ [" float" ] = json .array (12.34 ),
13+ [" empties" ] = json .array (json .array ())
1314 }
1415end
Original file line number Diff line number Diff line change @@ -84,6 +84,12 @@ func apiArray(state *lua.LState) int {
8484 }
8585 }
8686
87+ // Wrap user data in an array
88+ if custom , ok := state .CheckAny (1 ).(* lua.LUserData ); ok {
89+ state .Push (& lua.LUserData {Value : []any {custom .Value }})
90+ return 1
91+ }
92+
8793 // Otherwise, return an array
8894 fallthrough
8995 default :
Original file line number Diff line number Diff line change @@ -307,7 +307,7 @@ func TestEmptyArray(t *testing.T) {
307307 "str": ["hello"],
308308 "int": [12],
309309 "bool": [true],
310- "float": [12.34]
310+ "float": [12.34],
311+ "empties": [[]]
311312 }` , string (b ))
312-
313313}
You can’t perform that action at this time.
0 commit comments