As a newcomer to Angular 2, I find myself encountering a hurdle in filtering unnecessary data from a JSON object that is retrieved from a REST API. Below is an example of the JSON data I am working with:
{
"refDataId":{
"rdk":1,
"refDataTypeCD":"CNTRY",
"refDataStatusCD":"C",
"effStartDT":"2017-09-01",
"effEndDT":null,
"updtUserID":"EDMO",
"updtTS":"2017-09-05"
},
"refDataDescs":[
{
"rdk":1,
"langCD":"EN_CA",
"refDataNM":"Not Applicable",
"refDataShortNM":null,
"refDataDesc":"Not issued by ISO. Dummy country code for internal reference use only.",
"updtUserID":"EDMO",
"updtTS":"2017-09-05"
}
],
"refCntry":{
"cntryRdk":1,
"cntryIso2DigitCD":"0",
"cntryIso3DigitCD":null,
"cntryIsoNumericCD":0,
"riskTypeRdk":0
}
}
{
"refDataId":{
"rdk":2,
"refDataTypeCD":"CNTRY",
"refDataStatusCD":"C",
"effStartDT":"2017-09-01",
"effEndDT":null,
"updtUserID":"EDMO",
"updtTS":"2017-09-05"
},
"refDataDescs":[
{
"rdk":2,
"langCD":"EN_CA",
"refDataNM":"Afghanistan",
"refDataShortNM":null,
"refDataDesc":null,
"updtUserID":"EDMO",
"updtTS":"2017-09-05"
}
My requirement is to extract just these two fields from the dataset:
- "rdk":2,
- "refDataNM":"Afghanistan"
After extracting this data, my goal is to create a new JSON array containing only this information.
{"id":2,"itemName":"Afghanistan"},
{"id":3,"itemName":"Albania"}