Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
251 views
in Technique[技术] by (71.8m points)

Is it possible to replace the json property in the body response using kong response-transformation plugin?

Is it possible to replace the JSON property in the body response using the kong response-transformation plugin? if yes, how to can I accomplish it using the UI Konga?

Example of a response body:
[
  {
    "id": 1,
    "name": "Leanne Graham",
    "username": "Bret",
    "email": "Sincere@april.biz",
    "address": {
      "street": "Kulas Light",
      "suite": "Apt. 556",
      "city": "Gwenborough",
      "zipcode": "92998-3874",
      "geo": {
        "lat": "-37.3159",
        "lng": "81.1496"
      }
]

what I want is to replace the id for user_id for each user in the response json.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You cant do that only with the response-transformation plugin itself, but you can do that with a custom plugin or with Reedelk flow + Reedelk Transformer plugins (you may end up adding your custom logic to some groovy scripts). If you want to try this option, you can read about it here: https://konghq.com/blog/transform-your-requests-responses-with-the-kong-reedelk-transformer-plugin/

Or you may also look for info in the Reedelk Transformer documentation.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...