Skip to content

Commit

Permalink
style(tools): simplify the implementation of tools.cjson (#12316)
Browse files Browse the repository at this point in the history
Simplify the implementation of #12019.
  • Loading branch information
chronolaw authored Jan 15, 2024
1 parent 25da462 commit 00bab18
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions kong/tools/cjson.lua
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
local cjson = require "cjson.safe".new()
local constants = require "kong.constants"
local CJSON_MAX_PRECISION = require "kong.constants".CJSON_MAX_PRECISION


cjson.decode_array_with_array_mt(true)
cjson.encode_sparse_array(nil, nil, 2^15)
cjson.encode_number_precision(constants.CJSON_MAX_PRECISION)
cjson.encode_number_precision(CJSON_MAX_PRECISION)


local _M = {}


function _M.encode(json_text)
return cjson.encode(json_text)
end
_M.encode = cjson.encode
_M.decode_with_array_mt = cjson.decode

function _M.decode_with_array_mt(json_text)
return cjson.decode(json_text)
end

_M.array_mt = cjson.array_mt


return _M

0 comments on commit 00bab18

Please sign in to comment.