Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

java custom logic after reading data from BaaS

Not applicable
after fetching results from BaaS, i want to add custom java logic on data before response is sent to client. please suggest if it is possible and where i can get some sample code for this. thanks
Solved Solved
1 11 814
1 ACCEPTED SOLUTION

Either Java or Javascript callouts can be used in the Response flow of an Apigee Edge proxy. Within those callouts you can inspect or modify the response. It is super simple to do this in Javascript. For example, in Javascript:

var c = context.getVariable('response.content'); 

c = JSON.parse(c);

c.additionalProperty = "This is an additional property";

if (c.existingProperty) {
  delete c.existingProperty;  // remove an existing property
}

context.setVariable('response.content', JSON.stringify(c));

You can also do similar things in Java, but it is slightly more complicated, due to the greater degree of structure in Java itself. You could use the Jackson library to parse and stringify JSON, for example in Java.

View solution in original post

11 REPLIES 11