- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 01:40 AM
Hi All,
I have a JSOn Response in following format .... I am able to extract data for Scotland key but not for 'england-and-wales'.....is this because there is a hyphen in the key , if yes how to process it
JSON-
try {
var r = new sn_ws.RESTMessageV2('Holiday calendar', 'Default GET');
//override authentication profile
//authentication type ='basic'/ 'oauth2'
//r.setAuthenticationProfile(authentication type, profile name);
//set a MID server name if one wants to run the message on MID
//r.setMIDServer('MY_MID_SERVER');
//if the message is configured to communicate through ECC queue, either
//by setting a MID server or calling executeAsync, one needs to set skip_sensor
//to true. Otherwise, one may get an intermittent error that the response body is null
//r.setEccParameter('skip_sensor', true);
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
var parsedData = JSON.parse(responseBody);
for(var i = 0; i<parsedData.england-and-wales.events.length;i++){
//gs.warn(parsedData.england-and-wales.events[i].title);
}
}
catch(ex) {
var message = ex.message;
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 02:01 AM
Hello,
You can read data as below:
var parsedData = JSON.parse(responseBody);
for(var key in parsedData){
var tempObj1 = parsedData[key];
//From here, you can read each attributes
var division = tempObj1.division;
}
Thank you,
Ali
Thank you,
Ali

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 02:01 AM
Hello,
You can read data as below:
var parsedData = JSON.parse(responseBody);
for(var key in parsedData){
var tempObj1 = parsedData[key];
//From here, you can read each attributes
var division = tempObj1.division;
}
Thank you,
Ali
Thank you,
Ali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 03:20 AM
Hi Ahmmed,
Your solution worked, just wondering whats wrong with my approach ? why does it work for scotland and not for england ?