Response Transformer complex jsons #7256
Replies: 7 comments
-
Hi, There is no way to do this with the current request-transformer plugin to the best of my knowledge. Contributions welcomed! |
Beta Was this translation helpful? Give feedback.
-
any idea what is lacking in this? dont know lua but a quick search found this https://github.com/harningt/luajson does it just not have a json library that will work currently? |
Beta Was this translation helpful? Give feedback.
-
These methods splitstring and setjsonprop should do the trick when added to the https://github.com/Kong/kong/blob/master/kong/plugins/response-transformer/body_transformer.lua
Same method can be used to nil and replace elements/lists in nested json (or non nested, won't break old functionality :P ). Would be neat to have someone who has Kong benchmark tests actually run it on some deep nested payloads and see how efficient it is. Once I get motivated enough I might submit a PR, rather someone else do it though hah. |
Beta Was this translation helpful? Give feedback.
-
FWIW, I have a case where we would like to remove/replace a nested JSON value. Has anyone has a chance to take a look at implementing this improvement? |
Beta Was this translation helpful? Give feedback.
-
My code works if you dump into the response transformer or even the request transformer it could too heh. On my growing list of todo's but not a priority atm for me. |
Beta Was this translation helpful? Give feedback.
-
I'm wondering if this issue has been fixed in Kong 1.3.0. As it's not working for me, I'm trying to figure out if I'm missing something or that's the way it still behaves. |
Beta Was this translation helpful? Give feedback.
-
@preranashekhar it hasn't changed. But you can try the pre-function or post-function plugin to achieve the transformation you need |
Beta Was this translation helpful? Give feedback.
-
Response Transformer can't remove fields from complex jsons like:
I tried the following two operations:
curl -X POST http://kong:8001/apis/cebdca24-91f3-490f-bbaf-d5746c212d52/plugins --data "name=response-transformer" --data "config.remove.json=address.fieldtoremove"
curl -X POST http://kong:8001/apis/cebdca24-91f3-490f-bbaf-d5746c212d52/plugins --data "name=response-transformer" --data "config.remove.json=fieldtoremove"
Is there some other way or is this not working?
Same Issue for Lists like:
curl -X POST http://kong:8001/apis/cebdca24-91f3-490f-bbaf-d5746c212d52/plugins --data "name=response-transformer" --data "config.remove.json=fieldtoremove"
Beta Was this translation helpful? Give feedback.
All reactions