The library lljson could encode sparse arrays as objects instead of throwing an error
SuzannaLinn Resident
For example:
t = {}
t[10] = true
print(lljson.encode(t))
returns:
[null,null,null,null,null,null,null,null,null,true]
But:
t = {}
t[11] = true
print(lljson.encode(t))
throws the error:
Cannot serialise table: excessively sparse array
It could instead be encoded as an object.
Or always encoded as an object when
#t == 0 or next(t, #t) ~= nil
.Log In