The JSON serialization currently ignores any custom implementations of __pairs, __ipairs for tables. As a result, the JSON produced is not the one the user would expect.
The following code snippet demostrates the issue:
local m = {
__pairs = function(self)
-- Return nothing
return function() return nil, nil end, self, nil
end
}
local mytbl = {A = 1, B = 2, C = 3}
setmetatable(mytbl, m)
print("printing keys and values")
for k,v in pairs(mytbl) do
print(k, v) -- Does not execute even once
end
Ext.IO.SaveFile("test", Ext.DumpExport(mytbl)) -- Will have A, B, C
The __pairs metamethod in the snippet is setup to never return anything, yet the JSON file created at the end will contain all values of the table.
A possible use case where this would interfere would be serializing a custom data structure with iterator metamethods implemented. Any internal keys related to the data structure's implementation would end up in the JSON even if __pairs, __ipairs had been overwritten to skip them.
The issue likely stems from this method using next() directly:
Extender Version
v57, v58
Game Version
v3.6.117.3735
Bug Summary
The JSON serialization currently ignores any custom implementations of
__pairs
,__ipairs
for tables. As a result, the JSON produced is not the one the user would expect.The following code snippet demostrates the issue:
The
__pairs
metamethod in the snippet is setup to never return anything, yet the JSON file created at the end will contain all values of the table.A possible use case where this would interfere would be serializing a custom data structure with iterator metamethods implemented. Any internal keys related to the data structure's implementation would end up in the JSON even if
__pairs
,__ipairs
had been overwritten to skip them.The issue likely stems from this method using
next()
directly:Links
No response