Hi:
What would be the proper script for pulling the â.idâ from the 2nd member âname: wakandaâ from the below quoted JSON sample?
Basically, I need to be able to go through all the members of this JSON object and test if the .name begins/contains âwakandaâ . If it does, i write to an environment variable with "AuthorizationServerId: âValue of IDâ
Lets assume this JSON contains a bunch of members (not just the two in the below sample.
[
{
âidâ: âaus1d5w434jv2qFgW2p7â,
ânameâ: âdefaultâ,
âdescriptionâ: âDefault Authorization Server for your Applicationsâ,
âaudiencesâ: [
âapi://defaultâ
],
âissuerâ: âhttps://wakanda.okta.com/oauth2/defaultâ,
âstatusâ: âACTIVEâ,
âcreatedâ: â2018-06-12T16:00:16.000Zâ,
âlastUpdatedâ: â2018-06-12T16:00:16.000Zâ,
âcredentialsâ: {
âsigningâ: {
ârotationModeâ: âAUTOâ,
âlastRotatedâ: â2018-06-12T16:00:16.000Zâ,
ânextRotationâ: â2018-09-10T16:00:16.000Zâ,
âkidâ: âIt1zc8es8Lh6-gAsOlH9Z-nmA2HC0ys5_6gCN7FXZK8â
}
}
},
{
âidâ: âaus1dfrdn0Gvwq0Tc2p7â,
ânameâ: âwakandaâ,
âdescriptionâ: âBroad audience for wakandaâ,
âaudiencesâ: [
âwakandaâ
],
âissuerâ: âhttps://wakanda.okta.com/oauth2/aus1dfrdn0Gvwq0Tc2p7â,
âstatusâ: âACTIVEâ,
âcreatedâ: â2018-06-13T01:03:42.000Zâ,
âlastUpdatedâ: â2018-06-13T01:03:42.000Zâ,
âcredentialsâ: {
âsigningâ: {
ârotationModeâ: âAUTOâ,
âlastRotatedâ: â2018-06-13T01:03:42.000Zâ,
ânextRotationâ: â2018-09-11T01:03:42.000Zâ,
âkidâ: â5dhkhiVOzjYGG1aBxWca5DxYN90XIVjugJB0vzJF8Wgâ
}
}
}
]
Of course, I start off with a âvar jsonData = JSON.parse(responseBody);â
my test outline is:
if jsonData.name != âwakandaâ
// do nothing
//if name = wakanda , write id to variable
postman.setEnvironmentVariable(âauthorizationServerIdâ, â"â + jsonData.id + â"â);