From 478d1fa46f5fcb331b36191baaeb8f3b7816bb75 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Thu, 21 Sep 2023 11:21:06 +0200 Subject: [PATCH] fix(rockspec): make lua-cjson dependency explicit (#23) --- lua-resty-ljsonschema-scm-1.rockspec | 1 + src/resty/ljsonschema/metaschema.lua | 12 ++---------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/lua-resty-ljsonschema-scm-1.rockspec b/lua-resty-ljsonschema-scm-1.rockspec index 7525f4e..c854cdc 100644 --- a/lua-resty-ljsonschema-scm-1.rockspec +++ b/lua-resty-ljsonschema-scm-1.rockspec @@ -28,6 +28,7 @@ description = { dependencies = { "lua >= 5.1", "net-url", + "lua-cjson", } build = { diff --git a/src/resty/ljsonschema/metaschema.lua b/src/resty/ljsonschema/metaschema.lua index 707f687..3775fd2 100644 --- a/src/resty/ljsonschema/metaschema.lua +++ b/src/resty/ljsonschema/metaschema.lua @@ -155,16 +155,8 @@ local metaschema = [[ -local cjson = require "cjson" - - --- test decode with array_mt, to not change global settings -local t = cjson.decode("[]") -local status = getmetatable(t) == cjson.array_mt - +local cjson = require("cjson").new() cjson.decode_array_with_array_mt(true) -local schema = cjson.decode(metaschema) -cjson.decode_array_with_array_mt(status) -- restore old state -return schema +return cjson.decode(metaschema)