Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style(tools): simplify the implementation of tools.cjson #12316

Merged
merged 3 commits into from
Jan 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading