How to extract Values/Data from JSON Payload?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 06:36 AM - edited 11-03-2022 06:44 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 06:45 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 07:01 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 07:03 AM
What's the API you are using ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 07:33 AM
Import Set API(REST), it is an inbound request