Diff

util/datamapper.lua @ 11481:b2f9782497dd

util.datamapper: Don't include empty unwrapped arrays Since there is no way to distinguish an empty such array from a zero-length array. Dropping it seems like the least annoying thing to do.
author Kim Alvefur <zash@zash.se>
date Wed, 24 Mar 2021 00:48:02 +0100
parent 11479:377a9eaf7bef
child 12133:11060c8919b6
line wrap: on
line diff
--- a/util/datamapper.lua	Wed Mar 24 00:34:22 2021 +0100
+++ b/util/datamapper.lua	Wed Mar 24 00:48:02 2021 +0100
@@ -138,7 +138,10 @@
 						out[prop] = parse_object(propschema, c);
 					end
 				elseif proptype == "array" then
-					out[prop] = parse_array(propschema, s);
+					local a = parse_array(propschema, s);
+					if a and a[1] ~= nil then
+						out[prop] = a;
+					end
 				else
 					error("unreachable")
 				end