I’m trying to write a custom plugin to transform response body. I could’ve used a response transformer plugin, but my response body json is complex, so I want to remove few fields from it.
I tried using post-function plugin to write my custom lua code but it doesn’t let me import cjson, so I’m unable to decode the response and remove specific keys from it.
My lua code in body_filter:
local cjson = require(“cjson”)
local body = cjson.decode(kong.response.get_raw_body())
– set custom key’s value to 1
body.subKeyFoo.subSubKey = 1;
This is what I get:
require cjson not allowed within sandbox “kong”