Skip to content

Commit

Permalink
test(core.json): add an example for encode empty array (#10985)
Browse files Browse the repository at this point in the history
  • Loading branch information
xuruidong authored Mar 4, 2024
1 parent 2dc055b commit d6a3db3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions t/core/json.t
Original file line number Diff line number Diff line change
Expand Up @@ -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":{}}
Expand Down

0 comments on commit d6a3db3

Please sign in to comment.