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

Flat Response from JSON

How do I get a flat response as output instead of JSON array

Solved Solved
0 3 142
1 ACCEPTED SOLUTION

the response should be plain text? 

You can use a JS Callout to do that. The JS looks like this: 

var input = JSON.parse(context.getVariable('response.content'));
var output =
  "EmployeeRoleType: " + input.organisation.employee.role.type + '\n' +
  "Employee Name: " + input.organisation.employee.name + '\n' +
  "EmployeeDept: " + input.organisation.employee.department + '\n';

context.setVariable('response.header.content-type', 'text/plain');
context.setVariable('response.content', output);

 

View solution in original post

3 REPLIES 3