From 049dc46796ec46a44b7d33a2075aa6fe5d180256 Mon Sep 17 00:00:00 2001 From: James Rodovich Date: Thu, 8 Mar 2018 18:56:20 -0600 Subject: [PATCH] Add option to ignore mismatched array lengths due to `null`/`undefined`. --- lua/json/decode/composite.lua | 1 + lua/json/decode/state.lua | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/json/decode/composite.lua b/lua/json/decode/composite.lua index 0dda1dd..8dae0f5 100644 --- a/lua/json/decode/composite.lua +++ b/lua/json/decode/composite.lua @@ -23,6 +23,7 @@ local _ENV = nil local defaultOptions = { array = { allowEmptyElement = false, + ignoreLength = false, trailingComma = true }, object = { diff --git a/lua/json/decode/state.lua b/lua/json/decode/state.lua index a269d7c..c778f80 100644 --- a/lua/json/decode/state.lua +++ b/lua/json/decode/state.lua @@ -101,7 +101,7 @@ function state_ops.end_array(self) -- Not an empty array self:put_value(true) end - if self.active_state ~= #self.active then + if self.active_state ~= #self.active and not self.options.array.ignoreLength then -- Store the length in self.active.n = self.active_state end -- 2.11.4.GIT