mod_rest: Return an error for unknown fields in JSON input
authorKim Alvefur <zash@zash.se>
Fri, 07 Feb 2020 20:49:07 +0100
changeset 3889 1ec45dbc7db5
parent 3888 f84ede3e9e3b
child 3890 b64b08b7bf8e
mod_rest: Return an error for unknown fields in JSON input Helps you discover typos and such.
mod_rest/jsonmap.lib.lua
--- a/mod_rest/jsonmap.lib.lua	Thu Feb 06 21:03:17 2020 +0000
+++ b/mod_rest/jsonmap.lib.lua	Fri Feb 07 20:49:07 2020 +0100
@@ -464,6 +464,8 @@
 			elseif typ[1] == "func" then
 				s:add_child(typ[5](v)):up();
 			end
+		else
+			return nil, "unknown-field";
 		end
 	end