How do I get a flat response as output instead of JSON array
Solved! Go to 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);
😁
I need more explanation to have a chance of guessing what you mean by "flat response".
How about showing an example of what you want?
the output response should not be in the form of an array.
{
'organisation' : {
'employee': {
'role': {
'type': 'manager',
}
'name': 'abc',
'department': 'xyz'
}
}
}
Instead of this JSON Array the response should be
EmployeeRoleType: Manager
Employee Name: abc
EmployeeDept: xyz
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);