From d6a3db3ee2738436a634c3a6addd02c9cdfca035 Mon Sep 17 00:00:00 2001 From: Ruidong-X Date: Mon, 4 Mar 2024 17:08:02 +0800 Subject: [PATCH] test(core.json): add an example for encode empty array (#10985) --- t/core/json.t | 3 +++ 1 file changed, 3 insertions(+) diff --git a/t/core/json.t b/t/core/json.t index 6966f914cf6e..a7caf8daedc8 100644 --- a/t/core/json.t +++ b/t/core/json.t @@ -132,12 +132,15 @@ qr/\{"b":\{"a":\{"b":"table: 0x[\w]+"\}\}\}/ local core = require("apisix.core") local data = core.json.decode('{"arr":[]}') ngx.say(core.json.encode(data)) + local data = { arr = setmetatable({}, core.json.array_mt)} + ngx.say(core.json.encode(data)) local data = core.json.decode('{"obj":{}}') ngx.say(core.json.encode(data)) } } --- response_body {"arr":[]} +{"arr":[]} {"obj":{}}