This is an automated email from the ASF dual-hosted git repository.
monkeydluffy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new d6a3db3ee test(core.json): add an example for encode empty array
(#10985)
d6a3db3ee is described below
commit d6a3db3ee2738436a634c3a6addd02c9cdfca035
Author: Ruidong-X <[email protected]>
AuthorDate: Mon Mar 4 17:08:02 2024 +0800
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 6966f914c..a7caf8dae 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":{}}