I have a function in Typescript that extracts specific values from a JSON data object, some of which may be empty. How can I retrieve only certain data fields?
Here is the function:
let datosCod;
for (let get in Object.keys(transfConsData)) {
const value = transfConsData[get];
if (value.Country === 'Colombia') {
datosCod = value;
}
}
This is what the variable dataCod
contains:
{ Country: 'Colombia',
Ser: '',
Ins: 'blue',
BBDD: ''}
My objective is to extract the following information:
{ Country: 'Colombia',
Ins: 'blue'}
totalValues = 2