Hello! im trying to change the response to change to camel case to snake, so i change the json body like this:
function _M.transform_json_body(conf, buffered_data)
local json_body = read_json_body(buffered_data)
if json_body == nil then
return
end
kong.log.info("transform body", json_body)
local newJsonBody = {}
for key,value in pairs(json_body) do
newJsonBody[toSnake(key)] = value
end
...
the rest of the code are taking now the newJsonBody table, but it doenst work, i want to do:
"body": {
"data": {
"host": "rxxxxxxxx",
"clientIp": "xxxxxxxxx",
"expirationMonth": "09",
"email": "xxxxxxxxxx",
"apiKey": "xxxxxxxxxx",
}
}
to be
"body": {
"data": {
"host": "rxxxxxxxx",
"client_ip": "xxxxxxxxx",
"expiration_month": "09",
"email": "xxxxxxxxxx",
"api_key": "xxxxxxxxxx",
}
}
this is my config. yml
config:
extract:
body:
- "data"
- "error"
but it doesn work, notice that the key are passing throught a function toSnake. Any helps please.