How to extract Values/Data from JSON Payload?

Ankita9
Tera Contributor

Hi All,

 

How can we get the data/values passed in a JSON payload into an OnAfter transform Script?

 

For eg : Payload

{"u_class":"MS SQL DataBase","u_operation":"Update","u_ci_identifier":"CI000082","u_first_level_support":"ABA-SUPPORT","u_support_hours":"Server"}

 

I want to get these 2 values("ABA-SUPPORT" and "Server") from the payload and store it in an array in OnAfter Script

9 REPLIES 9

kamlesh kjmar
Mega Sage
Mega Sage

Hi @Ankita9 ,

 

Provided you have stored it in  a variable you can simply dot walk as shown below

var myArr = [];
var data = {"u_class":"MS SQL DataBase","u_operation":"Update","u_ci_identifier":"CI000082","u_first_level_support":"ABA-SUPPORT","u_support_hours":"Server"}
myArr.push(data.u_first_level_support);
myArr.push(data.u_support_hours);

 

Regards,

Kamlesh

Hi Kamlesh,

 

Thanks for your response. 

But the JSON Payload will be sent via Postman/3rd party tool, Whenever the payload is sent, "var data" should auto populate with the current payload passed, How can we achieve that?

What's the API you are using ?

Import Set API(REST), it is an inbound request