Skip to content

Commit

Permalink
feat(PDK): ensure that the PDK uses a separate cjson instance
Browse files Browse the repository at this point in the history
and has settings with the encoding of numbers with a precision of 16
decimals
  • Loading branch information
ms2008 committed Jan 4, 2024
1 parent bf80308 commit cb4fdc5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions kong/pdk/request.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ local PHASES = phase_checker.phases


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


local function new(self)
Expand Down
3 changes: 2 additions & 1 deletion kong/pdk/response.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@


local buffer = require "string.buffer"
local cjson = require "cjson.safe"
local cjson = require "cjson.safe".new()
local checks = require "kong.pdk.private.checks"
local phase_checker = require "kong.pdk.private.phases"
local utils = require "kong.tools.utils"
local request_id = require "kong.tracing.request_id"
local constants = require "kong.constants"

cjson.encode_sparse_array(nil, nil, 2^15)
cjson.encode_number_precision(16)

local ngx = ngx
Expand Down
5 changes: 4 additions & 1 deletion kong/pdk/service/request.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-- Module for manipulating the request sent to the Service.
-- @module kong.service.request

local cjson = require "cjson.safe"
local cjson = require "cjson.safe".new()
local buffer = require "string.buffer"
local checks = require "kong.pdk.private.checks"
local phase_checker = require "kong.pdk.private.phases"
Expand All @@ -24,6 +24,9 @@ local validate_headers = checks.validate_headers
local check_phase = phase_checker.check
local escape = require("kong.tools.uri").escape

cjson.encode_sparse_array(nil, nil, 2^15)
cjson.encode_number_precision(16)


local PHASES = phase_checker.phases

Expand Down
2 changes: 2 additions & 0 deletions kong/pdk/service/response.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ local check_phase = phase_checker.check


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


local replace_dashes = string_tools.replace_dashes
Expand Down

0 comments on commit cb4fdc5

Please sign in to comment.